Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Json Object" type does not keep object order #148

Closed
rockeet opened this issue Nov 17, 2015 · 4 comments
Closed

"Json Object" type does not keep object order #148

rockeet opened this issue Nov 17, 2015 · 4 comments
Labels
solution: invalid the issue is not related to the library

Comments

@rockeet
Copy link

rockeet commented Nov 17, 2015

for json: { "b" : "B", "a" : "A" }
The iteration order is by lexical order of keys, but it should be the original order in the json object.

@gregmarr
Copy link
Contributor

The JSON specification says that the data is stored in an unordered fashion, so any order is acceptable.

@nlohmann
Copy link
Owner

Hi, @gregmarr is right. JSON does not specify an order in which keys of an object are stored. My library uses an std::map, so the perceived order is lexicographically. This is conforming the JSON specification.

If you can implement a container that preserves the order of keys, you could use this one in the linear via template types.

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Nov 17, 2015
@rockeet
Copy link
Author

rockeet commented Nov 21, 2015

Thanks, now I use my gold_hash_map as map, and ignored the compare and allocator.

@bernau84
Copy link

Or you can use Niels https://github.com/nlohmann/fifo_map as I do.
Thank you @nlohmann twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

4 participants