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.

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

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

Fork me on GitHub