wrap

wrap(exception) Class Public methods

[]

[](object, opts = {}) Class Public methods If object is string-like, parse the string and return the parsed result as a Ruby data structure. Otherwise generate a JSON text from the Ruby data structure object and return it. The opts argument is passed through to generate/parse respectively. See generate and parse for their documentation.

const_defined_in?

const_defined_in?(modul, constant) Class Public methods

iconv

iconv(to, from, string) Class Public methods Encodes string using Ruby's String.encode

restore

restore(source, proc = nil, options = {}) Class Public methods Alias for: load

dump

dump(obj, anIO = nil, limit = nil) Instance Public methods Dumps obj as a JSON string, i.e. calls generate on the object and returns the result. If anIO (an IO-like object or an object that responds to the write method) was given, the resulting JSON is written to it. If the number of nested arrays or objects exceeds limit, an ArgumentError exception is raised. This argument is similar (but not exactly the same!) to the limit argument in Marshal.dump. The default options for the gen

fast_generate

fast_generate(obj, opts = nil) Instance Public methods Generate a JSON document from the Ruby data structure obj and return it. This method disables the checks for circles in Ruby objects. WARNING: Be careful not to pass any Ruby data structures with circles as obj argument because this will cause JSON to go into an infinite loop.

generate

generate(obj, opts = nil) Instance Public methods Generate a JSON document from the Ruby data structure obj and return it. state is a JSON::State object, or a Hash like object (responding to to_hash), or an object convertible into a hash by a to_h method, that is used as or to configure a State object. It defaults to a state object, that creates the shortest possible JSON text in one line, checks for circular data structures and doesn't allow NaN, Infinity, and -Infinity. A

load

load(source, proc = nil, options = {}) Instance Public methods Load a ruby data structure from a JSON source and return it. A source can either be a string-like object, an IO-like object, or an object responding to the read method. If proc was given, it will be called with any nested Ruby object as an argument recursively in depth first order. To modify the default options pass in the optional options argument as well. BEWARE: This method is meant to serialise data from trusted use

parse

parse(source, opts = {}) Instance Public methods Parse the JSON document source into a Ruby data structure and return it. opts can have the following keys: max_nesting: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false. It defaults to 100. allow_nan: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the Parser. This option defaults to false. symbolize_names: If set to