Module: JSON
- Defined in:
- opal/stdlib/json.rb
Class Attribute Summary collapse
-
.create_id ⇒ Object
Returns the value of attribute create_id.
Class Method Summary collapse
- .[](value, options = {}) ⇒ Object
- .dump(obj, io = nil, limit = nil) ⇒ Object
-
.from_object(js_object, options = {}) ⇒ Object
Raw js object => opal object.
- .generate(obj, options = {}) ⇒ Object
- .load(source, options = {}) ⇒ Object
- .parse(source, options = {}) ⇒ Object
- .parse!(source, options = {}) ⇒ Object
Class Attribute Details
.create_id ⇒ Object
Returns the value of attribute create_id
56 57 58
# File 'opal/stdlib/json.rb', line 56 def create_id @create_id end
Class Method Details
.[](value, options = {}) ⇒ Object
61 62 63 64 65 66 67
# File 'opal/stdlib/json.rb', line 61 def self.[](value, options = {}) if String === value parse(value, options) else generate(value, options) end end
.dump(obj, io = nil, limit = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104
# File 'opal/stdlib/json.rb', line 93 def self.dump(obj, io = nil, limit = nil) string = generate(obj) if io io = io.to_io if io.responds_to? :to_io io.write string io else string end end
.from_object(js_object, options = {}) ⇒ Object
Raw js object => opal object
.generate(obj, options = {}) ⇒ Object
89 90 91
# File 'opal/stdlib/json.rb', line 89 def self.generate(obj, options = {}) obj.to_json(options) end
.load(source, options = {}) ⇒ Object
77 78 79
# File 'opal/stdlib/json.rb', line 77 def self.load(source, options = {}) from_object(`$parse(source)`, options) end
.parse(source, options = {}) ⇒ Object
69 70 71
# File 'opal/stdlib/json.rb', line 69 def self.parse(source, options = {}) from_object(`$parse(source)`, options.merge(parse: true)) end
.parse!(source, options = {}) ⇒ Object
73 74 75
# File 'opal/stdlib/json.rb', line 73 def self.parse!(source, options = {}) parse(source, options) end