1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-29 23:01:16 +03:00

minor changes

This commit is contained in:
Niels
2015-06-25 00:40:16 +02:00
parent 5bad95f48e
commit 3ffedea5c4
7 changed files with 339 additions and 46 deletions

View File

@ -0,0 +1,30 @@
#include <json.hpp>
using namespace nlohmann;
int main()
{
// create a JSON object
json object =
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two"
std::cout << object["two"] << "\n\n";
// change element with key "three"
object["three"] = 3;
// output changed array
std::cout << std::setw(4) << object << "\n\n";
// mention nonexisting key
object["four"];
// write to nonexisting key
object["five"]["really"]["nested"] = true;
// output changed object
std::cout << std::setw(4) << object << '\n';
}

View File

@ -0,0 +1,19 @@
2
{
"one": 1,
"three": 3,
"two": 2
}
{
"five": {
"really": {
"nested": true
}
},
"four": null,
"one": 1,
"three": 3,
"two": 2
}

View File

@ -0,0 +1,15 @@
#include <json.hpp>
using namespace nlohmann;
int main()
{
// create a JSON object
json object =
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two"
std::cout << object["two"] << '\n';
}

View File

@ -0,0 +1 @@
2