Are dump and parse guaranteed to be inverse to each other? #2788
-
The following example seems to imply that any json can be dumped and re-parsed, and will stay the same. Is this guaranteed to work on any nlohmann::json object? nlohmann::json j;
j["k"] = {"v1", "v2"};
std::string jj = j.dump();
nlohmann::json jjj = nlohmann::json::parse(jj);
std::cout << j << std::endl; // {"k":["v1","v2"]}
std::cout << jjj << std::endl; // couts the same |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I would say no, it wouldn't be guaranteed, since there can be things in the |
Beta Was this translation helpful? Give feedback.
I would say no, it wouldn't be guaranteed, since there can be things in the
json
object that can't be represented in a JSON file, such as NAN or infinity, or non-utf8 strings.