Class: Zona::JSONElement
- Inherits:
-
Object
- Object
- Zona::JSONElement
- Defined in:
- zona/OZonesJSON.rb
Overview
This class represents an element described by a JSON string In practice, this is represented by a hash, result of parsing the JSON string.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (String) [](key)
Accesses the value of a JSON element key.
-
- (JSONElement) initialize(json_hash = nil)
constructor
Initializes an instance.
-
- (Object) initialize_json(json_str, root_element)
Initializes an instance with a JSON description.
Constructor Details
- (JSONElement) initialize(json_hash = nil)
Initializes an instance
73 74 75 |
# File 'zona/OZonesJSON.rb', line 73 def initialize(json_hash=nil) @json_hash=json_hash end |
Instance Method Details
- (String) [](key)
Accesses the value of a JSON element key
92 93 94 |
# File 'zona/OZonesJSON.rb', line 92 def [](key) @json_hash[key.to_sym] end |
- (Object) initialize_json(json_str, root_element)
Initializes an instance with a JSON description
80 81 82 83 84 85 86 87 |
# File 'zona/OZonesJSON.rb', line 80 def initialize_json(json_str, root_element) rc = OZonesJSON.build_json(json_str,root_element) @json_hash = rc if Zona.is_error?(rc) || (rc.size == 0) @json_hash=nil end end |