push_back__initializer_list.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 JSON values
00008     json object = {{"one", 1}, {"two", 2}};
00009     json null;
00010 
00011     // print values
00012     std::cout << object << '\n';
00013     std::cout << null << '\n';
00014 
00015     // add values:
00016     object.push_back({"three", 3});  // object is extended
00017     object += {"four", 4};           // object is extended
00018     null.push_back({"five", 5});     // null is converted to array
00019 
00020     // print values
00021     std::cout << object << '\n';
00022     std::cout << null << '\n';
00023 
00024     // would throw:
00025     //object.push_back({1, 2, 3});
00026 }


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