-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
solution: invalidthe issue is not related to the librarythe issue is not related to the library
Description
If you construct a string of the JSON payload using dump() and then use parse() to deserialize it, the contents of the former object don't match the latter when there are escape characters. Example pseudo-code
void test_case()
{
nlohmann::json fields;
fields["one"] = std::string("one");
fields["two"] = std::string("two three");
fields["three"] = std::string("three \"four\"");
std::string payload = fields.dump();
nlohmann::json parsed_fields = fields_t::parse(payload);
test_check_eq(parsed_fields.size(), fields.size());
test_check_eq(parsed_fields["one"], fields["one"]);
test_check_eq(parsed_fields["two"], fields["two"]);
test_check_eq(parsed_fields["three"], fields["three"]);
}
Here parsed_fields["three"] == std::string("three \\\"four\\\""). If this is expected, then what should be done to parsed_fields in this case to recover the original contents?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
solution: invalidthe issue is not related to the librarythe issue is not related to the library