toJSON

See also: parseJSON

Serializes an object to the corresponding JSON representation.

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"
}