This commit is contained in:
Niels 2016-05-08 20:28:20 +02:00
parent fadf286653
commit 9ecf83f630
6 changed files with 210 additions and 2 deletions

View file

@ -0,0 +1,26 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json object = {{"one", 1}, {"two", 2}};
json null;
// print values
std::cout << object << '\n';
std::cout << null << '\n';
// add values:
object.push_back({"three", 3}); // object is extended
object += {"four", 4}; // object is extended
null.push_back({"five", 5}); // null is converted to array
// print values
std::cout << object << '\n';
std::cout << null << '\n';
// would throw:
//object.push_back({1, 2, 3});
}

View file

@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/wZF4dRHjfCyjb3rx"><b>online</b></a>

View file

@ -0,0 +1,4 @@
{"one":1,"two":2}
null
{"four":4,"one":1,"three":3,"two":2}
[["five",5]]