Class: RustyJson::Parser
- Inherits:
-
Object
- Object
- RustyJson::Parser
- Defined in:
- lib/rusty_json/parser.rb
Constant Summary collapse
- BASE_TYPES =
{ String => 'String', Fixnum => 'i64', Float => 'f64', }
Instance Method Summary collapse
-
#initialize(name, json) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(name, json) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 17 |
# File 'lib/rusty_json/parser.rb', line 12 def initialize(name, json) @name = name @json = json @struct_names = Set.new @structs = Set.new end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rusty_json/parser.rb', line 19 def parse @parsed = JSON.parse(@json) if @parsed.is_a? Hash struct = parse_hash(@name, @parsed) end struct.to_s end |