toJSON

Prev Next

See also: parseJSON

Serializes an object to the corresponding JSON representation.

Tooltip

Syntax: $toJSON(object[,format=false[,classField=class]])

Parameter

Description

object

The object to be serialized.

format

Optional, default value = false, true to generate a formatted JSON.

classField

Optional, default value = 'class', specifies the property in which the class name is to be searched. This may need to be set to 'clazz'.

forceNativeTypes

Optional, default = false, true to enforce native JSON types, e.g. (long is written as JSON number, list is written as array).

Returns the object as a JSON string.

Example: $toJSON($el(5))

Syntax

$toJSON(object[,format=false[,classField=class]])

Parameter

Name

Description

object

The object to be serialized.

format

Optional, default value = false, true to generate a formatted JSON.

classField

Optional, default value = 'class', specifies the property in which the class name is to be searched. This may need to be set to 'clazz'.

Return value

The object as JSON

Example

Syntax

Result

$toJSON($el(12))

"Element12SimpleText"

$toJSON($el(11))

{"el12":"Element12SimpleText"}

$toJSON($el(11),$true)

{
	"el12": "Element12SimpleText"
}