deserializeJSON

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

deserializeJSON(json [, strictMapping, useCustomSerializer]) → returns any

Argument Reference

json 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

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub