Skip to content

How to use nlohmann::ordered_json with to_json? #4568

Answered by gregmarr
ashleyzhang216 asked this question in Q&A
Discussion options

You must be logged in to vote

Both of these are producing output in the expected order. Are you sure that you're quoting the relevant code here?

    std::cout << j.dump(4);

    std::stringstream file;
    file << std::setw(4) << j << std::endl;
    std::cout << file.str() << std::endl;

https://godbolt.org/z/o5hPM7879

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ashleyzhang216
Comment options

@gregmarr
Comment options

Answer selected by ashleyzhang216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants