more documentation
This commit is contained in:
parent
27b0a4d170
commit
844bfd39b5
10 changed files with 238 additions and 48 deletions
27
doc/examples/basic_json__CompatibleIntegerNumberType.cpp
Normal file
27
doc/examples/basic_json__CompatibleIntegerNumberType.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create values of different integer types
|
||||
short n42 = 42;
|
||||
int n23 = 23;
|
||||
long n1024 = 1024;
|
||||
int_least32_t n17 = 17;
|
||||
uint8_t n8 = 8;
|
||||
|
||||
// create JSON numbers
|
||||
json j42(n42);
|
||||
json j23(n23);
|
||||
json j1024(n1024);
|
||||
json j17(n17);
|
||||
json j8(n8);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j42 << '\n';
|
||||
std::cout << j23 << '\n';
|
||||
std::cout << j1024 << '\n';
|
||||
std::cout << j17 << '\n';
|
||||
std::cout << j8 << '\n';
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
42
|
||||
23
|
||||
1024
|
||||
17
|
||||
8
|
21
doc/examples/basic_json__number_float_t.cpp
Normal file
21
doc/examples/basic_json__number_float_t.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create values of different floating-point types
|
||||
json::number_float_t v_ok = 3.141592653589793;
|
||||
json::number_float_t v_nan = NAN;
|
||||
json::number_float_t v_infinity = INFINITY;
|
||||
|
||||
// create JSON numbers
|
||||
json j_ok(v_ok);
|
||||
json j_nan(v_nan);
|
||||
json j_infinity(v_infinity);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j_ok << '\n';
|
||||
std::cout << j_nan << '\n';
|
||||
std::cout << j_infinity << '\n';
|
||||
}
|
3
doc/examples/basic_json__number_float_t.output
Normal file
3
doc/examples/basic_json__number_float_t.output
Normal file
|
@ -0,0 +1,3 @@
|
|||
3.14159265358979
|
||||
null
|
||||
null
|
14
doc/examples/basic_json__number_integer_t.cpp
Normal file
14
doc/examples/basic_json__number_integer_t.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON number from number_integer_t
|
||||
json::number_integer_t value = 42;
|
||||
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j << '\n';
|
||||
}
|
1
doc/examples/basic_json__number_integer_t.output
Normal file
1
doc/examples/basic_json__number_integer_t.output
Normal file
|
@ -0,0 +1 @@
|
|||
42
|
Loading…
Add table
Add a link
Reference in a new issue