module MultiJson::OkJson

def valparse(ts)

Returns the parsed value and any trailing tokens.
Parses a "value" in the sense of RFC 4627.
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