Method: Transcriptic::OkJson#decode
- Defined in:
- lib/vendor/okjson.rb
#decode(s) ⇒ Object
Decodes a json document in string s and returns the corresponding ruby value. String s must be valid UTF-8. If you have a string in some other encoding, convert it first.
String values in the resulting structure will be UTF-8.
42 43 44 45 46 47 48 49 |
# File 'lib/vendor/okjson.rb', line 42 def decode(s) ts = lex(s) v, ts = textparse(ts) if ts.length > 0 raise Transcriptic::OkJson::ParserError, 'trailing garbage' end v end |