DeserializeJson

Hey all,

Got a quick question about deserializeJSON… does it produce an ordered struct when deserializing… Meaning if I get an array of objects from a rest endpoint and the properties order is always the same, can I hash the deserialized structure to product a “key” to see if the next time I get the same object if anything has changed… As I understand it if the order of properties has changed then the hash would also produce a different key, so thats why I am asking.

Yes I could run a structSort first but if Lucee always creates an ordered struct then there is no need to and I can save the overhead.

Cheers

Gary

I can’t answer your exact question, but can offer a caveat. An object in JSON is an unordered collection of name value pairs (see json.org and ECMA 404.

So however Lucee handles the ordering, the source data ought not be considered to be in any specific order in the first place; the ordering will simply be a reflection of the implementation that created the JSON in the first place.

:-/

if you cfdump it out, Lucee indicates if the struct is ordered or not

image

As you can see Lucee does use ordered structs when deserialising