fx-lange/ofxSyncedParams

order is mixed up

fx-lange opened this issue · 3 comments

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

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

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

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 ...

added an orderIdx

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