Spec-Zone.ru › ColdFusion

arraySetMetadata

Sets metadata for items of an array. Useful when using serializeJSON with ambiguous data.

arraySetMetadata(array, metadata) → returns void

Member Function Syntax

someArray.setMetadata(metadata)

This function requires Adobe ColdFusion 2016.0.2 and up. Not supported on Lucee, etc.
  • CF2016.0.2+
  • See Also: arrayGetMetadata structGetMetadata structSetMetadata

    Argument Reference

    array array
    Required

    The array for which to set the metadata.

    metadata struct
    Required

    The metadata struct to set.

    Examples
    Sample code invoking the arraySetMetadata function

    Serialize an array to JSON

    Outputs serialized JSON for an array containing various data types

    inputs = ["2016.02", 42.0, "Yes", "No", "32830", {"t1": "Yes"}, ["1","yes","3",false,"null","null"]];
    metadata = {items: ["numeric", "integer", "string", "boolean", "string", {t1: {type:"string",ignore:true}}, {items: ["integer","boolean","string","string","string","null"]}]};
    arraySetMetadata(inputs,metadata);
    writeOutput(serializeJSON(inputs));

    Expected Result: [2016.02,42.0,"Yes",false,"32830",{},[1,true,"3","false","null","null"]]

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

    Spec-Zone.ru

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