Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trycf/51c901961fc7681a15e5b0d9b856a07f to your computer and use it in GitHub Desktop.

Select an option

Save trycf/51c901961fc7681a15e5b0d9b856a07f to your computer and use it in GitHub Desktop.
TryCF Gist
<cfset animal = createobject("component", "Animal")>
<cfsavecontent variable="jsonstr">{"animal":{"id":1,"name":"chicken","eats":"chicken food","says":"cluck cluck"}}</cfsavecontent>
<cfset decoded = deserializejson(jsonstr).animal>
<cfset animal.setId(decoded.id).setName(decoded.name).setEats(decoded.eats).setSays(decoded.says)>
<cfscript>
// Lucee
typedArray = arrayNew(dimension: 1, synchronized : true, type:"Animal");
//ACF v1 - syntax listed would throw error in Lucee, but creates an array type Animals
//typedArray = arrayNew(dimension: 1, issynchronized : true, typename:"Animal");
//ACF v2 - this is the alleged way, but it does not create an array type Animals
//typedArray = arrayNew["Animal"]( dimensions:1, issynchronized : true);
//ACF v3 - this is the alleged way, but AND does create an array type Animals
//typedArray = arrayNew["Animal"]( 1, true);
typedArray[1] = animal;
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment