instance method
encode
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v3.0.20Available in: v2.3.18 v3.0.20
Signature
encode(x)
Encodes x into a json text. It may contain only Array, Hash, String, Numeric, true, false, nil. (Note, this list excludes Symbol.) X itself must be an Array or a Hash. No other value can be encoded, and an error will be raised if x contains any other value, such as Nan, Infinity, Symbol, and Proc, or if a Hash key is not a String. Strings contained in x must be valid UTF-8.
Parameters
-
xreq
Source
# File activesupport/lib/active_support/json/backends/okjson.rb, line 407
def encode(x)
case x
when Hash then objenc(x)
when Array then arrenc(x)
else
raise Error, 'root value must be an Array or a Hash'
end
end
Defined in activesupport/lib/active_support/json/backends/okjson.rb line 407
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::OkJson