more documentation
This commit is contained in:
parent
770b9820fe
commit
c85dbef98f
9 changed files with 441 additions and 85 deletions
15
doc/examples/basic_json__string_t.cpp
Normal file
15
doc/examples/basic_json__string_t.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an string_t value
|
||||
json::string_t value = "The quick brown fox jumps over the lazy doc";
|
||||
|
||||
// create a JSON string from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__string_t.output
Normal file
1
doc/examples/basic_json__string_t.output
Normal file
|
@ -0,0 +1 @@
|
|||
"The quick brown fox jumps over the lazy doc"
|
12
doc/examples/basic_json__string_t_value_type.cpp
Normal file
12
doc/examples/basic_json__string_t_value_type.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON string directly from a string literal
|
||||
json j("The quick brown fox jumps over the lazy doc");
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__string_t_value_type.output
Normal file
1
doc/examples/basic_json__string_t_value_type.output
Normal file
|
@ -0,0 +1 @@
|
|||
"The quick brown fox jumps over the lazy doc"
|
18
doc/examples/operator_serialize.cpp
Normal file
18
doc/examples/operator_serialize.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
|
||||
// serialize without indentation
|
||||
std::cout << j_object << "\n\n";
|
||||
std::cout << j_array << "\n\n";
|
||||
|
||||
// serialize with indentation
|
||||
std::cout << std::setw(4) << j_object << "\n\n";
|
||||
std::cout << std::setw(2) << j_array << "\n\n";
|
||||
}
|
17
doc/examples/operator_serialize.output
Normal file
17
doc/examples/operator_serialize.output
Normal file
|
@ -0,0 +1,17 @@
|
|||
{"one":1,"two":2}
|
||||
|
||||
[1,2,4,8,16]
|
||||
|
||||
{
|
||||
"one": 1,
|
||||
"two": 2
|
||||
}
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16
|
||||
]
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue