This is my old home .. find me now at andyj.github.io

Logging/storing structures and arrays easily
Posted:

For loggin purposes I wanted to store off a simple structure so I could capture a couple of value at a point in time. Luckily with Java powering CFML this was relativiely easy as you have access to the string object

aStc = {name1 = "val 1",name2 = "val 2",name3 = "val 3"}; writeDump(aStc.toString());

You can actually do this arrays and even json structures too:

aAry = ['val 1',' val 2','val 3']; writeDump(aAry.toString() ); // Below is Railo only I think aJson = {name1:"val 1",name2:"val 2"}; writeDump(aJson.toString() );

You can even use the strings to compare structures easily:

aStc2 = {name1 = "val 1",name2 = "val 2",name3 = "val 3"}; aStc3 = {name3 = "val 3",name1 = "val 1",name2 = "val 2"}; writeDump( compare(aStc2.toString(),aStc3.toString()) ); // should return 0 for no differences

comments powered by Disqus
© AndyJarrett 2013 | RSS Feed