Method: OkJson#objparse
- Defined in:
- lib/heroku/kensa/okjson.rb
#objparse(ts) ⇒ Object
Parses an “object” in the sense of RFC 4627. Returns the parsed value and any trailing tokens.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/heroku/kensa/okjson.rb', line 91 def objparse(ts) ts = eat('{', ts) obj = {} if ts[0][0] == '}' return obj, ts[1..-1] end k, v, ts = pairparse(ts) obj[k] = v if ts[0][0] == '}' return obj, ts[1..-1] end loop do ts = eat(',', ts) k, v, ts = pairparse(ts) obj[k] = v if ts[0][0] == '}' return obj, ts[1..-1] end end end |