Sha256: 13019866bb3ea75cf7058b317ac647e301d2e539b38ad0576541058f4b16c0bd
Contents?: true
Size: 560 Bytes
Versions: 6
Compression:
Stored size: 560 Bytes
Contents
class JSON def self.load(string) error_ptr = Pointer.new(:id) obj = NSJSONSerialization.JSONObjectWithData(string.to_data, options:0, error:error_ptr) if obj == nil raise error_ptr[0].description end obj end end class Object def to_json raise "Invalid JSON object" unless NSJSONSerialization.isValidJSONObject(self) error_ptr = Pointer.new(:id) data = NSJSONSerialization.dataWithJSONObject(self, options:0, error:error_ptr) if data == nil raise error_ptr[0].description end data.to_str end end
Version data entries
6 entries across 6 versions & 1 rubygems