json::parse string is order #2234
-
Hello nlohmann, I have a question, when using json::parse string, the output json string is sorted by key, is there a way to let json save the key sequence of the original string |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Answered in the FAQ https://nlohmann.github.io/json/home/faq/ |
Beta Was this translation helpful? Give feedback.
-
When #2258 is merged, it will be possible to use type |
Beta Was this translation helpful? Give feedback.
-
I am trying to do the same thing here and I am getting loads of compilation errors, here is my snippet: #include <nlohmann/json.hpp>
#include <iostream>
using json = nlohmann::ordered_json;
int main(void) {
json j = json::parse("{\"b\":2,\"a\":1}");
std::cout<< j <<std::endl;
return 0;
} Am I using it wrong? |
Beta Was this translation helpful? Give feedback.
When #2258 is merged, it will be possible to use type
ordered_json
which maintains the insertion order of object keys.