fx-lange / ofxSyncedParams

synced ofParameters for remote and web UIs
16 stars 2 forks source link

order is mixed up #3

Closed fx-lange closed 9 years ago

fx-lange commented 9 years ago

The order of keys is not specified in JSON and JsonCpp uses std::map. This results in an alphabetic order instead of the order the elements are added.

http://stackoverflow.com/questions/7582300/jsoncpp-stop-making-it-write-based-on-elements-alphabetical-order

fx-lange commented 9 years ago

maybe https://github.com/miloyip/rapidjson

https://github.com/nlohmann/json looks really great but does not keep track of the insertion order ...

fx-lange commented 9 years ago

rapidjson indeed works for parsing the gui to json without loosing the order: https://github.com/fx-lange/ofxSyncedParams/tree/rapidjson works for the datGui example.

but of course in the remote example the order is still alphabetic because I'm still using jsoncpp objects to setup the ofxGui.

I think adding an orderIdx as an attribute might be the better choice: jsoncpp is more common in the oF community, no additional libraries, less work ...

fx-lange commented 9 years ago

added an orderIdx

now for both cases (oF -> oF and oF -> datGui) the order in the remoteUIs is correct