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, OpenBD, etc.

arraySetMetadata 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

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"]]


Fork me on GitHub