open-source-parsers / open-source-parsers/jsoncpp
Keep order of fields as they are added, not sorting alphabetically
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.9k
- Forks
- 2.7k
- Avg merge
- 31m
- Merged PRs (30d)
- 1
Description
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue concerns the container used by Json::Value and the field-order behavior during JSON output. Start by reviewing those existing paths and the insertion-order example. Done means fields are emitted in insertion order rather than alphabetically, with tests covering the reported example and existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100