This commit is contained in:
Niels 2016-08-21 12:35:40 +02:00
parent eef8059003
commit b4571360df
16 changed files with 298 additions and 101 deletions

View file

@ -0,0 +1,28 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text
char text[] = R"(
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
"Url": "http://www.example.com/image/481989943",
"Height": 125,
"Width": 100
},
"Animated" : false,
"IDs": [116, 943, 234, 38793]
}
}
)";
// parse and serialize JSON
json j_complete = json::parse(text);
std::cout << std::setw(4) << j_complete << "\n\n";
}

View file

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

View file

@ -0,0 +1,20 @@
{
"Image": {
"Animated": false,
"Height": 600,
"IDs": [
116,
943,
234,
38793
],
"Thumbnail": {
"Height": 125,
"Url": "http://www.example.com/image/481989943",
"Width": 100
},
"Title": "View from 15th Floor",
"Width": 800
}
}

View file

@ -0,0 +1,13 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text given as std::vector
std::vector<uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
// parse and serialize JSON
json j_complete = json::parse(text);
std::cout << std::setw(4) << j_complete << "\n\n";
}

View file

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

View file

@ -0,0 +1,6 @@
[
1,
2,
3
]

View file

@ -0,0 +1,13 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text given as std::vector
std::vector<uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
// parse and serialize JSON
json j_complete = json::parse(text.begin(), text.end());
std::cout << std::setw(4) << j_complete << "\n\n";
}

View file

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

View file

@ -0,0 +1,6 @@
[
1,
2,
3
]

View file

@ -5,7 +5,7 @@ using json = nlohmann::json;
int main()
{
// a JSON text
std::string text = R"(
auto text = R"(
{
"Image": {
"Width": 800,
@ -44,4 +44,4 @@ int main()
// parse (with callback) and serialize JSON
json j_filtered = json::parse(text, cb);
std::cout << std::setw(4) << j_filtered << '\n';
}
}

View file

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