Advertisement
cepxuozab

MiniFiedJson

Jun 2nd, 2023
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. [{"array": [1, 2, 3]"bool": true"double": 42.1"int": 42"map": {"key": "value"}"null": null"string": "hello"}]
  2.  
  3. #include <cassert>
  4. #include <chrono>
  5. #include <sstream>
  6. #include <string_view>
  7.  
  8. #include "json.h"
  9.  
  10. using namespace json;
  11. using namespace std::literals;
  12.  
  13. // namespace
  14. void MinifiedLoad() {
  15.         std::string s = "[{\"array\":[1,2,3],\"bool\":true,\"double\":42.1,\"int\":42,\"map\":{\"key\":\"value\"},\"null\":null,\"string\":\"hello\"}]";
  16.         Array arr;
  17.         arr.emplace_back(Dict{
  18.             {"int"s, 42},
  19.             {"double"s, 42.1},
  20.             {"null"s, nullptr},
  21.             {"string"s, "hello"s},
  22.             {"array"s, Array{1, 2, 3}},
  23.             {"bool"s, true},
  24.             {"map"s, Dict{{"key"s, "value"s}}},
  25.             });
  26.         std::stringstream strm;
  27.         strm << s;
  28.         const auto doc = Load(strm);
  29.        
  30.         Print(doc, std::cout);
  31.     }
  32.  
  33. int main() {
  34.     MinifiedLoad();
  35. }
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement