-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worked on #102: more documentation and examples
- Loading branch information
Showing
33 changed files
with
538 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
SRCDIR = ../src | ||
|
||
all: doxygen | ||
|
||
clean: | ||
rm -fr me.nlohmann.json.docset html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/a74tSggkWP5Zo0Ee"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/TZmhplJw3tl08RFN"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/clvCFZxlFEerhtk8"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/85XpxnwbJZR1PVtz"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/JYP6JpBzl8Q9xQDZ"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/csiUCov9Mquff3ZZ"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/5ZglUDvkQ0VxYxQ4"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[1,2,3,4,5] | ||
null | ||
[1,2,3,4,5,6,7] | ||
["first","second"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/xtErbxTG2iIC5wHh"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"one":1,"two":2} | ||
null | ||
{"four":4,"one":1,"three":3,"two":2} | ||
{"A":"a","B":"b"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/g5pkLUCrBVoNPRyE"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
value = {"translation":{"cow":"Kuh","dog":"Hund"}} | ||
object = {"one":"eins","two":"zwei"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a target="_blank" href="http://melpon.org/wandbox/permlink/UsEo3yK2GsjH8CyA"><b>online</b></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
value = ["the good","the fast","the ugly"] | ||
string = the bad |
Oops, something went wrong.