worked on #102: more documentation and examples
This commit is contained in:
parent
19d550c044
commit
c012b29ae5
33 changed files with 538 additions and 86 deletions
|
@ -1,5 +1,7 @@
|
|||
SRCDIR = ../src
|
||||
|
||||
all: doxygen
|
||||
|
||||
clean:
|
||||
rm -fr me.nlohmann.json.docset html
|
||||
|
||||
|
|
23
doc/examples/operator__equal.cpp
Normal file
23
doc/examples/operator__equal.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.000000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
|
||||
std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
|
||||
std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
|
||||
std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__equal.link
Normal file
1
doc/examples/operator__equal.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/a74tSggkWP5Zo0Ee"><b>online</b></a>
|
4
doc/examples/operator__equal.output
Normal file
4
doc/examples/operator__equal.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] == [1,2,4] false
|
||||
{"A":"a","B":"b"} == {"A":"a","B":"b"} true
|
||||
17 == 17 true
|
||||
"foo" == "bar" false
|
23
doc/examples/operator__greater.cpp
Normal file
23
doc/examples/operator__greater.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.0000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " == " << array_2 << " " << (array_1 > array_2) << '\n';
|
||||
std::cout << object_1 << " == " << object_2 << " " << (object_1 > object_2) << '\n';
|
||||
std::cout << number_1 << " == " << number_2 << " " << (number_1 > number_2) << '\n';
|
||||
std::cout << string_1 << " == " << string_2 << " " << (string_1 > string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__greater.link
Normal file
1
doc/examples/operator__greater.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/TZmhplJw3tl08RFN"><b>online</b></a>
|
4
doc/examples/operator__greater.output
Normal file
4
doc/examples/operator__greater.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] == [1,2,4] false
|
||||
{"A":"a","B":"b"} == {"A":"a","B":"b"} false
|
||||
17 == 17.0000000000001 false
|
||||
"foo" == "bar" true
|
23
doc/examples/operator__greaterequal.cpp
Normal file
23
doc/examples/operator__greaterequal.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.0000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n';
|
||||
std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n';
|
||||
std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n';
|
||||
std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__greaterequal.link
Normal file
1
doc/examples/operator__greaterequal.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/clvCFZxlFEerhtk8"><b>online</b></a>
|
4
doc/examples/operator__greaterequal.output
Normal file
4
doc/examples/operator__greaterequal.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] >= [1,2,4] false
|
||||
{"A":"a","B":"b"} >= {"A":"a","B":"b"} true
|
||||
17 >= 17.0000000000001 false
|
||||
"foo" >= "bar" true
|
23
doc/examples/operator__less.cpp
Normal file
23
doc/examples/operator__less.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.0000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n';
|
||||
std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n';
|
||||
std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n';
|
||||
std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__less.link
Normal file
1
doc/examples/operator__less.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/85XpxnwbJZR1PVtz"><b>online</b></a>
|
4
doc/examples/operator__less.output
Normal file
4
doc/examples/operator__less.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] == [1,2,4] true
|
||||
{"A":"a","B":"b"} == {"A":"a","B":"b"} false
|
||||
17 == 17.0000000000001 true
|
||||
"foo" == "bar" false
|
23
doc/examples/operator__lessequal.cpp
Normal file
23
doc/examples/operator__lessequal.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.0000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n';
|
||||
std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n';
|
||||
std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n';
|
||||
std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__lessequal.link
Normal file
1
doc/examples/operator__lessequal.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/JYP6JpBzl8Q9xQDZ"><b>online</b></a>
|
4
doc/examples/operator__lessequal.output
Normal file
4
doc/examples/operator__lessequal.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] <= [1,2,4] true
|
||||
{"A":"a","B":"b"} <= {"A":"a","B":"b"} true
|
||||
17 <= 17.0000000000001 true
|
||||
"foo" <= "bar" false
|
23
doc/examples/operator__notequal.cpp
Normal file
23
doc/examples/operator__notequal.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create several JSON values
|
||||
json array_1 = {1, 2, 3};
|
||||
json array_2 = {1, 2, 4};
|
||||
json object_1 = {{"A", "a"}, {"B", "b"}};
|
||||
json object_2 = {{"B", "b"}, {"A", "a"}};
|
||||
json number_1 = 17;
|
||||
json number_2 = 17.000000000000001L;
|
||||
json string_1 = "foo";
|
||||
json string_2 = "bar";
|
||||
|
||||
// output values and comparisons
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << array_1 << " == " << array_2 << " " << (array_1 != array_2) << '\n';
|
||||
std::cout << object_1 << " == " << object_2 << " " << (object_1 != object_2) << '\n';
|
||||
std::cout << number_1 << " == " << number_2 << " " << (number_1 != number_2) << '\n';
|
||||
std::cout << string_1 << " == " << string_2 << " " << (string_1 != string_2) << '\n';
|
||||
}
|
1
doc/examples/operator__notequal.link
Normal file
1
doc/examples/operator__notequal.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/csiUCov9Mquff3ZZ"><b>online</b></a>
|
4
doc/examples/operator__notequal.output
Normal file
4
doc/examples/operator__notequal.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3] == [1,2,4] true
|
||||
{"A":"a","B":"b"} == {"A":"a","B":"b"} false
|
||||
17 == 17 false
|
||||
"foo" == "bar" true
|
24
doc/examples/push_back.cpp
Normal file
24
doc/examples/push_back.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
json null;
|
||||
|
||||
// print values
|
||||
std::cout << array << '\n';
|
||||
std::cout << null << '\n';
|
||||
|
||||
// add values
|
||||
array.push_back(6);
|
||||
array += 7;
|
||||
null += "first";
|
||||
null += "second";
|
||||
|
||||
// print values
|
||||
std::cout << array << '\n';
|
||||
std::cout << null << '\n';
|
||||
}
|
1
doc/examples/push_back.link
Normal file
1
doc/examples/push_back.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/5ZglUDvkQ0VxYxQ4"><b>online</b></a>
|
4
doc/examples/push_back.output
Normal file
4
doc/examples/push_back.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
[1,2,3,4,5]
|
||||
null
|
||||
[1,2,3,4,5,6,7]
|
||||
["first","second"]
|
24
doc/examples/push_back__object_t__value.cpp
Normal file
24
doc/examples/push_back__object_t__value.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json object = {{"one", 1}, {"two", 2}};
|
||||
json null;
|
||||
|
||||
// print values
|
||||
std::cout << object << '\n';
|
||||
std::cout << null << '\n';
|
||||
|
||||
// add values
|
||||
object.push_back(json::object_t::value_type("three", 3));
|
||||
object += json::object_t::value_type("four", 4);
|
||||
null += json::object_t::value_type("A", "a");
|
||||
null += json::object_t::value_type("B", "b");
|
||||
|
||||
// print values
|
||||
std::cout << object << '\n';
|
||||
std::cout << null << '\n';
|
||||
}
|
1
doc/examples/push_back__object_t__value.link
Normal file
1
doc/examples/push_back__object_t__value.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/xtErbxTG2iIC5wHh"><b>online</b></a>
|
4
doc/examples/push_back__object_t__value.output
Normal file
4
doc/examples/push_back__object_t__value.output
Normal file
|
@ -0,0 +1,4 @@
|
|||
{"one":1,"two":2}
|
||||
null
|
||||
{"four":4,"one":1,"three":3,"two":2}
|
||||
{"A":"a","B":"b"}
|
19
doc/examples/swap__object_t.cpp
Normal file
19
doc/examples/swap__object_t.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
|
||||
|
||||
// create an object_t
|
||||
json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
|
||||
|
||||
// swap the object stored in the JSON value
|
||||
value["translation"].swap(object);
|
||||
|
||||
// output the values
|
||||
std::cout << "value = " << value << '\n';
|
||||
std::cout << "object = " << object << '\n';
|
||||
}
|
1
doc/examples/swap__object_t.link
Normal file
1
doc/examples/swap__object_t.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/g5pkLUCrBVoNPRyE"><b>online</b></a>
|
2
doc/examples/swap__object_t.output
Normal file
2
doc/examples/swap__object_t.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
value = {"translation":{"cow":"Kuh","dog":"Hund"}}
|
||||
object = {"one":"eins","two":"zwei"}
|
19
doc/examples/swap__string_t.cpp
Normal file
19
doc/examples/swap__string_t.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json value = { "the good", "the bad", "the ugly" };
|
||||
|
||||
// create string_t
|
||||
json::string_t string = "the fast";
|
||||
|
||||
// swap the object stored in the JSON value
|
||||
value[1].swap(string);
|
||||
|
||||
// output the values
|
||||
std::cout << "value = " << value << '\n';
|
||||
std::cout << "string = " << string << '\n';
|
||||
}
|
1
doc/examples/swap__string_t.link
Normal file
1
doc/examples/swap__string_t.link
Normal file
|
@ -0,0 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/UsEo3yK2GsjH8CyA"><b>online</b></a>
|
2
doc/examples/swap__string_t.output
Normal file
2
doc/examples/swap__string_t.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
value = ["the good","the fast","the ugly"]
|
||||
string = the bad
|
Loading…
Add table
Add a link
Reference in a new issue