Method: JSON::Parser#parse

Defined in:
lib/parser.rb

#parseObject

Parses the current JSON string and returns the complete data structure as a result.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/parser.rb', line 36

def parse
  reset
  until eos?
    case
    when scan(ARRAY_OPEN)
      return parse_array
    when scan(OBJECT_OPEN)
      return parse_object
    when skip(IGNORE)
      ;
    when !((value = parse_value).equal? UNPARSED)
      return value
    else
      raise ParserError, "source '#{peek(20)}' not in JSON!"
    end
  end
end