Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created April 2, 2013 01:41
Show Gist options
  • Save adamcameron/5289311 to your computer and use it in GitHub Desktop.
Save adamcameron/5289311 to your computer and use it in GitHub Desktop.
Demonstrating ColdFusion messing with boolean values from JSON
<cfsavecontent variable="json">
{
"trueMatch1": {
"setting": true
},
"falseMatch": {
"setting": false
},
"trueMatch2": {
"setting": true
}
}
</cfsavecontent>
<cfscript>
struct = deserializeJSON(json);
writeDump(var=struct, label="Whole thing");
writeDump(var=structFindValue(struct, true, "all"), label="Matched values for 'true'");
writeOutput("Value of struct.trueMatch1.setting: [#struct.trueMatch1.setting#]<br>");
writeOutput("Value of struct.trueMatch2.setting: [#struct.trueMatch2.setting#]<br>");
shouldBeYes = struct.trueMatch1.setting;
writeOutput("shouldBeYes: [#shouldBeYes#]<br>");
writeDump(var=structFindValue(struct, shouldBeYes, "all"), label="Matches for value pulled out of the struct we're actually looking in");
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment