pretty_generate

pretty_generate(obj, opts = nil) Instance Public methods Generate a JSON document from the Ruby data structure obj and return it. The returned document is a prettier form of the document returned by unparse. The opts argument can be used to configure the generator. See the generate method for a more detailed explanation.

parse!

parse!(source, opts = {}) Instance Public methods Parse the JSON document source into a Ruby data structure and return it. The bang version of the parse method defaults to the more dangerous values for the opts hash, so be sure only to parse trusted source documents. opts can have the following keys: max_nesting: The maximum depth of nesting allowed in the parsed data structures. Enable depth checking with :max_nesting => anInteger. The parse! methods defaults to not doing max

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

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

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

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.

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

restore

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

iconv

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

const_defined_in?

const_defined_in?(modul, constant) Class Public methods