open-source-parsers/jsoncpp

Keep order of fields as they are added, not sorting alphabetically

Open

#1.202 geöffnet am 9. Juli 2020

Auf GitHub ansehen
 (21 Kommentare) (7 Reaktionen) (0 zugewiesene Personen)C++ (2.602 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (7.542 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 18h 26m) (10 gemergte PRs in 30 T)

Beschreibung

To use json files in a context where human readability makes sense, order of the fields insertion can make sense. As jsoncpp is sorting them alphabetically, it becomes hard to read the file and find related fields in ddifferent ends of the object. For example Json::Value root; root["name"] = "Test;" root["host"] = "127.0.0.1"; root["port"] = 80;

would be nice to have printed as

{ "name" : "Test, "host" : "127.0.0.1", "port" : 80 }

and not as

{ "host" : "127.0.0.1", "name" : "Test, "port" : 80 }

I actually succeeded to have this feature by replacing a container used by Json::Value with a custom one.

Contributor Guide