Method: Transcriptic::OkJson#textparse

Defined in:
lib/vendor/okjson.rb

#textparse(ts) ⇒ Object

Parses a “json text” in the sense of RFC 4627. Returns the parsed value and any trailing tokens. Note: this is almost the same as valparse, except that it does not accept atomic values.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vendor/okjson.rb', line 56

def textparse(ts)
  if ts.length < 0
    raise Transcriptic::OkJson::ParserError, 'empty'
  end

  typ, _, val = ts[0]
  case typ
  when '{' then objparse(ts)
  when '[' then arrparse(ts)
  else valparse(ts)
  end
end