Are v6 JSON objects order independent?

Learn how to use AAO by reading tutorials, and seek help from the AAO community.

Moderator: EN - Forum Moderators

Post Reply
User avatar
Enthalpy
Community Manager
Posts: 5172
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Are v6 JSON objects order independent?

Post by Enthalpy »

This is a question primarily for Unas, or anybody crazy enough to look at the v6 code:

I'm writing a Python package that manipulates the JSON trial_data file. I currently use Ordered Dictionaries to keep the listing of properties in the objects the same as in the editor-generated JSON. (Lists, of course, are lists.) So my package processing a blank would give the JSON as:

Code: Select all

{"profiles":[0],"evidence":[0],"places":[0],"sounds":[0],"music":[0],"popups":[0],"cross_examinations":[0],"scenes":[0],"scenes_aai":[0],"frames":[0],"ui":{"base":"classic","elements":[]}}
and not, say,

Code: Select all

{"places":[0],"popups":[0],"scenes":[0],"profiles":[0],"evidence":[0],"scenes_aai":[0],"music":[0],"cross_examinations":[0],"frames":[0],"ui":{"base":"classic","elements":[]},"sounds":[0]}
The same use of Ordered Dictionaries persists throughout the program, so the object that represents a foreground object is also stored as an Ordered Dictionary while I'm working with it in Python.

Will v6 have problems if I switch to regular dictionaries to save on memory? The data would be the same, but the order within objects changes. I know that order dependence in an object's name-value pair is terrible, but I want to make absolutely sure that Unas isn't using that for some sort of hack in the development phase.

Edit: I looked at the v6 code and then realized that nobody who codes like Unas would ever use order-dependent objects. Question answered, then.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
Post Reply