README.cpp
Go to the documentation of this file.
00001 #include <json.hpp>
00002 
00003 using json = nlohmann::json;
00004 
00005 int main()
00006 {
00007     // create a JSON object
00008     json j =
00009     {
00010         {"pi", 3.141},
00011         {"happy", true},
00012         {"name", "Niels"},
00013         {"nothing", nullptr},
00014         {
00015             "answer", {
00016                 {"everything", 42}
00017             }
00018         },
00019         {"list", {1, 0, 2}},
00020         {
00021             "object", {
00022                 {"currency", "USD"},
00023                 {"value", 42.99}
00024             }
00025         }
00026     };
00027 
00028     // add new values
00029     j["new"]["key"]["value"] = {"another", "list"};
00030 
00031     // count elements
00032     j["size"] = j.size();
00033 
00034     // pretty print with indent of 4 spaces
00035     std::cout << std::setw(4) << j << '\n';
00036 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06