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

the first attributes of JSON string is misplaced #1360

Closed
AmirHMousavi opened this issue Nov 15, 2018 · 1 comment
Closed

the first attributes of JSON string is misplaced #1360

AmirHMousavi opened this issue Nov 15, 2018 · 1 comment
Labels
solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)

Comments

@AmirHMousavi
Copy link

AmirHMousavi commented Nov 15, 2018

  • Reading a JSON file from given path. The pretty version created always the first standalone attributes/members of the JSON are moved to the end.
    for human readability, and in my project, it is very important that every thing be at its original location.
  • code used form samples given in the doc
std::ifstream i(R"(C:\file.json)");
json j;
i >> j;
std::ofstream o(R"(C:\pretty.json)");
o << std::setw(4) << j << std::endl;
  • the input JSON file looks like (an uglified version)
{"releaseVersion": "0.3.0","toolVersion": "11.0.1","ecus": [{"1":"2"},{"and 100 arrays and onjects"}],"params":[{" 200 arrays and objects here"}] 
  • the outputed JSON file looks like
{
    "ecus":  [
        {
        }
     ],
     "params": [
     ],
     "releaseVersion":"0.3.0",
     "toolVersion":"11.0.1"
}
  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

  • I am using the single_include version downloaded the json.hpp and put it as a header in the project directory and adding it to the source code by #include "json.hpp" and afterwards, using json=nlohmann::json;

  • no compilation error.

@nlohmann nlohmann added the solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope) label Nov 15, 2018
@nlohmann
Copy link
Owner

See the last note at https://github.com/nlohmann/json#notes. The library does not preserve the order of object keys, as it is not required by the standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)
Projects
None yet
Development

No branches or pull requests

2 participants