Method: MultiJson::OkJson#valenc

Defined in:
lib/multi_json/vendor/okjson.rb

#valenc(x) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/multi_json/vendor/okjson.rb', line 67

def valenc(x)
  case x
  when Hash then objenc(x)
  when Array then arrenc(x)
  when String then strenc(x)
  when Numeric then numenc(x)
  when true then "true"
  when false then "false"
  when nil then "null"
  else
    raise Error, "cannot encode #{x.class}: #{x.inspect}" unless x.respond_to?(:to_json)

    x.to_json
  end
end