Method: Nimbu::OkJson#encode
- Defined in:
- lib/vendor/nimbu/okjson.rb
#encode(x) ⇒ Object
Encodes x into a json text. It may contain only Array, Hash, String, Numeric, true, false, nil. (Note, this list excludes Symbol.) Strings contained in x must be valid UTF-8. Values that cannot be represented, such as Nan, Infinity, Symbol, and Proc, are encoded as null, in accordance with ECMA-262, 5th ed.
369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/vendor/nimbu/okjson.rb', line 369 def encode(x) case x when Hash then objenc(x) when Array then arrenc(x) when String then strenc(x) when Numeric then numenc(x) when Symbol then strenc(x.to_s) when true then "true" when false then "false" when nil then "null" else "null" end end |