Advertisement
cepxuozab

MinifyJson

Jun 23rd, 2024
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. std::string s = "[{\"array\":[1,2,3],\"bool\":true,\"double\":42.1,\"int\":42,\"map\":{\"key\":\"value\",\"bool_key\":false},\"null\":null,\"string\":\"hello\"}]";
  2.         Array arr;
  3.         arr.emplace_back(Dict{
  4.             {"int"s, 42},
  5.             {"double"s, 42.1},
  6.             {"null"s, nullptr},
  7.             {"string"s, "hello"s},
  8.             {"array"s, Array{1, 2, 3}},
  9.             {"bool"s, true},
  10.             {"map"s, Dict{{"key"s, "value"s}, {"bool_key"s, false}}},
  11.             });
  12.         std::stringstream strm;
  13.         strm << s;
  14.         const auto doc = Load(strm);
  15.         assert(doc.GetRoot() == arr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement