Spec-Zone.ru › ColdFusion

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

  • CF8+
  • Lucee
  • BL 1.0.0+
  • See Also: serializeJSON

    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

    CF 11+ Use custom serializer if defined. See: https://helpx.adobe.com/coldfusion/developing-applications/changes-in-coldfusion/restful-web-services-in-coldfusion.html

    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

    BoxLang:

    Version 1.0.0+ JSONDeserialize in BoxLang. Works with deserializeJSON with the bx-compat-cfml

    Examples
    Sample code invoking the deserializeJSON function

    Convert JSON into CF Structure

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

    Expected Result: Foundeo

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/deserializejson

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API