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, = {}) if String === value parse(value, ) else generate(value, ) 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
| 82 83 84 85 86 87 | # File 'opal/stdlib/json.rb', line 82 def self.from_object(js_object, = {}) [:object_class] ||= Hash [:array_class] ||= Array `to_opal(js_object, options.$$smap)` end | 
.generate(obj, options = {}) ⇒ Object
| 89 90 91 | # File 'opal/stdlib/json.rb', line 89 def self.generate(obj, = {}) obj.to_json() end | 
.load(source, options = {}) ⇒ Object
| 77 78 79 | # File 'opal/stdlib/json.rb', line 77 def self.load(source, = {}) from_object(`$parse(source)`, ) end | 
.parse(source, options = {}) ⇒ Object
| 69 70 71 | # File 'opal/stdlib/json.rb', line 69 def self.parse(source, = {}) from_object(`$parse(source)`, .merge(parse: true)) end | 
.parse!(source, options = {}) ⇒ Object
| 73 74 75 | # File 'opal/stdlib/json.rb', line 73 def self.parse!(source, = {}) parse(source, ) end |