Method: Azuki::OkJson#valparse

Defined in:
lib/vendor/azuki/okjson.rb

#valparse(ts) ⇒ Object

Parses a “value” in the sense of RFC 4627. Returns the parsed value and any trailing tokens.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vendor/azuki/okjson.rb', line 74

def valparse(ts)
  if ts.length < 0
    raise Error, 'empty'
  end

  typ, _, val = ts[0]
  case typ
  when '{' then objparse(ts)
  when '[' then arrparse(ts)
  when :val,:str then [val, ts[1..-1]]
  else
    raise Error, "unexpected #{val.inspect}"
  end
end