-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
dump() / parse() not idempotent #76
Labels
solution: invalid
the issue is not related to the library
Comments
I cannot reproduce the error. I added the following lines to the unit tests: // create JSON object
json fields;
fields["one"] = std::string("one");
fields["two"] = std::string("two three");
fields["three"] = std::string("three \"four\"");
// create another JSON object by deserializing the serialization
std::string payload = fields.dump();
json parsed_fields = json::parse(payload);
// check individual fields to match both objects
CHECK(parsed_fields["one"] == fields["one"]);
CHECK(parsed_fields["two"] == fields["two"]);
CHECK(parsed_fields["three"] == fields["three"]);
// check individual fields to match original input
CHECK(parsed_fields["one"] == std::string("one"));
CHECK(parsed_fields["two"] == std::string("two three"));
CHECK(parsed_fields["three"] == std::string("three \"four\""));
// check equality of the objects
CHECK(parsed_fields == fields);
// check equality of the serialized objects
CHECK(fields.dump() == parsed_fields.dump());
// check everything in one line
CHECK(fields == json::parse(fields.dump())); Am I missing something? |
nlohmann
added a commit
that referenced
this issue
May 30, 2015
nlohmann
added
solution: invalid
the issue is not related to the library
and removed
kind: bug
labels
May 30, 2015
Sorry for the mistake. My local repo was out of date; the current version of the code does not have this problem. |
No worries! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you construct a string of the JSON payload using
dump()
and then useparse()
to deserialize it, the contents of the former object don't match the latter when there are escape characters. Example pseudo-codeHere
parsed_fields["three"] == std::string("three \\\"four\\\"")
. If this is expected, then what should be done toparsed_fields
in this case to recover the original contents?The text was updated successfully, but these errors were encountered: