Method: Spring::OkJson#decode

Defined in:
lib/spring/json.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.



68
69
70
71
72
73
74
75
# File 'lib/spring/json.rb', line 68

def decode(s)
  ts = lex(s)
  v, ts = textparse(ts)
  if ts.length > 0
    raise Error, 'trailing garbage'
  end
  v
end