Class: JSON::Ext::Generator::State

Class | JSON::Ext::Generator::State
In: | ext/json/ext/generator/generator.c
Parent: | Object

This class is used to create State instances, that are use to hold data while generating a JSON text from a a Ruby data structure.

### Methods

allow_nan? allow_nan? array_nl array_nl array_nl= array_nl= check_circular? check_circular? configure configure forget forget from_state from_state indent indent indent= indent= max_nesting max_nesting max_nesting= max_nesting= new new object_nl object_nl object_nl= object_nl= remember remember seen? seen? space space space= space= space_before space_before space_before= space_before= to_h to_h

### Public Class methods

from_state(opts)

Creates a State object from opts, which ought to be Hash to create a new State instance configured by opts, something else to create an unconfigured instance. If opts is a State object, it is just returned.

from_state(opts)

Creates a State object from opts, which ought to be Hash to create a new State instance configured by opts, something else to create an unconfigured instance. If opts is a State object, it is just returned.

new(opts = {})

Instantiates a new State object, configured by opts.

opts can have the following keys:

- indent: a string used to indent levels (default: ’’),
- space: a string that is put after, a : or , delimiter (default: ’’),
- space_before: a string that is put before a : pair delimiter (default: ’’),
- object_nl: a string that is put at the end of a JSON object (default: ’’),
- array_nl: a string that is put at the end of a JSON array (default: ’’),
- check_circular: true if checking for circular data structures should be done, false (the default) otherwise.
- allow_nan: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false.

new(opts = {})

Instantiates a new State object, configured by opts.

opts can have the following keys:

- indent: a string used to indent levels (default: ’’),
- space: a string that is put after, a : or , delimiter (default: ’’),
- space_before: a string that is put before a : pair delimiter (default: ’’),
- object_nl: a string that is put at the end of a JSON object (default: ’’),
- array_nl: a string that is put at the end of a JSON array (default: ’’),
- check_circular: true if checking for circular data structures should be done, false (the default) otherwise.
- allow_nan: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false.

### Public Instance methods

allow_nan?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

allow_nan?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

array_nl()

This string is put at the end of a line that holds a JSON array.

array_nl()

This string is put at the end of a line that holds a JSON array.

array_nl=(array_nl)

This string is put at the end of a line that holds a JSON array.

array_nl=(array_nl)

This string is put at the end of a line that holds a JSON array.

check_circular?

Returns true, if circular data structures should be checked, otherwise returns false.

check_circular?

Returns true, if circular data structures should be checked, otherwise returns false.

configure(opts)

Configure this State instance with the Hash opts, and return itself.

configure(opts)

Configure this State instance with the Hash opts, and return itself.

forget(object)

Forget object for this generating run.

forget(object)

Forget object for this generating run.

indent()

This string is used to indent levels in the JSON text.

indent()

This string is used to indent levels in the JSON text.

indent=(indent)

This string is used to indent levels in the JSON text.

indent=(indent)

This string is used to indent levels in the JSON text.

max_nesting

This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked.

max_nesting

This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked.

max_nesting=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

max_nesting=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

object_nl()

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl()

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl=(object_nl)

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl=(object_nl)

This string is put at the end of a line that holds a JSON object (or Hash).

remember(object)

Remember object, to find out if it was already encountered (if a cyclic data structure is rendered).

remember(object)

Remember object, to find out if it was already encountered (if a cyclic data structure is rendered).

seen?(object)

Returns true, if object was already seen during this generating run.

seen?(object)

Returns true, if object was already seen during this generating run.

space()

This string is used to insert a space between the tokens in a JSON string.

space()

This string is used to insert a space between the tokens in a JSON string.

space=(space)

This string is used to insert a space between the tokens in a JSON string.

space=(space)

This string is used to insert a space between the tokens in a JSON string.

space_before()

This string is used to insert a space before the ’:’ in JSON objects.

space_before()

This string is used to insert a space before the ’:’ in JSON objects.

space_before=(space_before)

This string is used to insert a space before the ’:’ in JSON objects.

space_before=(space_before)

This string is used to insert a space before the ’:’ in JSON objects.

to_h

Returns the configuration instance variables as a hash, that can be passed to the configure method.

to_h

Returns the configuration instance variables as a hash, that can be passed to the configure method.

[Validate]