deserializeJSON

Converts a JSON (JavaScript Object Notation) string data representation into CFML data, such as a CFML structure or array.

deserializeJSON(jsonvar [, strictMapping, useCustomSerializer]) deserializeJSON(jsonstring [, strictMapping, file]) → returns any

deserializeJSON Argument Reference

jsonvar string
Required

A string that contains a valid JSON construct, or variable that represents one.

strictMapping boolean
Default: true

A Boolean value that specifies whether to convert the JSON strictly. If true everything becomes structures.

useCustomSerializer boolean
Default: true

Compatibility

Lucee:

Lucee has only support for the first two parameters

OpenBD:

In OpenBD it's possible to pass in a file path as third parameter instead of useCustomSerializer which will be used in place of the json passed with the first parameter You can pass the parameters as a structure ("ArgumentCollection") as well

Examples sample code invoking the deserializeJSON function

person = deserializeJSON( '{"company":"Foundeo","name":"Pete Freitag"}' );
writeOutput( person.company );

Expected Result: Foundeo


Fork me on GitHub