Spec-Zone.ru › ColdFusion

serialize

Serializes the object to a specified type

serialize( object, type, useCustomSerializer ) → returns string

  • CF11+
  • Lucee4.5+
  • See Also: deserialize

    Argument Reference

    object any
    Required

    An object to be serialized.

    type string
    Required

    A type to which the object will be serialized. ColdFusion, by default supports XML and JSON formats. You can also implement support for other types in the CustomSerializer CFC.

    useCustomSerializer boolean
    Default: true

    Whether to use the custom serializer or not. The custom serializer will be always used for XML deserialization.If false, the XML/JSON deserialization will be done using the default ColdFusion behavior.If any other type is passed with useCustomSerializer as false, then TypeNotSupportedException will be thrown.

    Examples
    Sample code invoking the serialize function

    Serialize with Lucee's default serializer (Script syntax)

    Lucee 5+ This will serialize the object using the default serialization mechanism.

    serialize({ "firstName": "John", "lastName": "Doe" });

    Expected Result: {"lastName":"Doe","firstName":"John"}

    Serialize to JSON (Script syntax)

    This will serialize the object to JSON using ColdFusion's default serialization mechanism.

    serialize({ "firstName": "John", "lastName": "Doe" }, 'json');

    Expected Result: {"lastName":"Doe","firstName":"John"}

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

    Spec-Zone.ru

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