more on #290
This commit is contained in:
parent
eef8059003
commit
b4571360df
16 changed files with 298 additions and 101 deletions
28
doc/examples/parse__array__parser_callback_t.cpp
Normal file
28
doc/examples/parse__array__parser_callback_t.cpp
Normal 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";
|
||||
}
|
1
doc/examples/parse__array__parser_callback_t.link
Normal file
1
doc/examples/parse__array__parser_callback_t.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/LvZQq5fybVH1nh9L"><b>online</b></a>
|
20
doc/examples/parse__array__parser_callback_t.output
Normal file
20
doc/examples/parse__array__parser_callback_t.output
Normal 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
|
||||
}
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/F8VaVFyys87qQRt5"><b>online</b></a>
|
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
13
doc/examples/parse__iteratortype__parser_callback_t.cpp
Normal file
13
doc/examples/parse__iteratortype__parser_callback_t.cpp
Normal 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";
|
||||
}
|
1
doc/examples/parse__iteratortype__parser_callback_t.link
Normal file
1
doc/examples/parse__iteratortype__parser_callback_t.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/ojh4Eeol4G9RgeRV"><b>online</b></a>
|
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue