Class: JSON
Defined Under Namespace
Classes: Malformed
Class Method Summary collapse
Class Method Details
.generate(object, pretty = false) ⇒ Object
15 16 17 18 |
# File 'lib/under_os/core/json.rb', line 15 def self.generate(object, pretty=false) = pretty ? NSJSONWritingPrettyPrinted : 0 NSJSONSerialization.dataWithJSONObject(object, options:, error:nil).to_s end |
.parse(string, encoding = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/under_os/core/json.rb', line 4 def self.parse(string, encoding=nil) error = Pointer.new(:object) data = NSJSONSerialization.JSONObjectWithData string.to_data(encoding), options:0, error:error if error[0] raise Malformed else data end end |