-
-
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.
added documentation for erase functions
- Loading branch information
Showing
10 changed files
with
327 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <json.hpp> | ||
|
||
using namespace nlohmann; | ||
|
||
int main() | ||
{ | ||
// create JSON values | ||
json j_boolean = true; | ||
json j_number_integer = 17; | ||
json j_number_float = 23.42; | ||
json j_object = {{"one", 1}, {"two", 2}}; | ||
json j_array = {1, 2, 4, 8, 16}; | ||
json j_string = "Hello, world"; | ||
|
||
// call erase | ||
j_boolean.erase(j_boolean.begin()); | ||
j_number_integer.erase(j_number_integer.begin()); | ||
j_number_float.erase(j_number_float.begin()); | ||
j_object.erase(j_object.find("two")); | ||
j_array.erase(j_array.begin() + 2); | ||
j_string.erase(j_string.begin()); | ||
|
||
// print values | ||
std::cout << j_boolean << '\n'; | ||
std::cout << j_number_integer << '\n'; | ||
std::cout << j_number_float << '\n'; | ||
std::cout << j_object << '\n'; | ||
std::cout << j_array << '\n'; | ||
std::cout << j_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,6 @@ | ||
null | ||
null | ||
null | ||
{"one":1} | ||
[1,2,8,16] | ||
null |
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,30 @@ | ||
#include <json.hpp> | ||
|
||
using namespace nlohmann; | ||
|
||
int main() | ||
{ | ||
// create JSON values | ||
json j_boolean = true; | ||
json j_number_integer = 17; | ||
json j_number_float = 23.42; | ||
json j_object = {{"one", 1}, {"two", 2}}; | ||
json j_array = {1, 2, 4, 8, 16}; | ||
json j_string = "Hello, world"; | ||
|
||
// call erase | ||
j_boolean.erase(j_boolean.begin(), j_boolean.end()); | ||
j_number_integer.erase(j_number_integer.begin(), j_number_integer.end()); | ||
j_number_float.erase(j_number_float.begin(), j_number_float.end()); | ||
j_object.erase(j_object.find("two"), j_object.end()); | ||
j_array.erase(j_array.begin() + 1, j_array.begin() + 3); | ||
j_string.erase(j_string.begin(), j_string.end()); | ||
|
||
// print values | ||
std::cout << j_boolean << '\n'; | ||
std::cout << j_number_integer << '\n'; | ||
std::cout << j_number_float << '\n'; | ||
std::cout << j_object << '\n'; | ||
std::cout << j_array << '\n'; | ||
std::cout << j_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,6 @@ | ||
null | ||
null | ||
null | ||
{"one":1} | ||
[1,8,16] | ||
null |
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,17 @@ | ||
#include <json.hpp> | ||
|
||
using namespace nlohmann; | ||
|
||
int main() | ||
{ | ||
// create a JSON object | ||
json j_object = {{"one", 1}, {"two", 2}}; | ||
|
||
// call erase | ||
auto count_one = j_object.erase("one"); | ||
auto count_three = j_object.erase("three"); | ||
|
||
// print values | ||
std::cout << j_object << '\n'; | ||
std::cout << count_one << " " << count_three << '\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,2 @@ | ||
{"two":2} | ||
1 0 |
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,15 @@ | ||
#include <json.hpp> | ||
|
||
using namespace nlohmann; | ||
|
||
int main() | ||
{ | ||
// create a JSON array | ||
json j_array = {0, 1, 2, 3, 4, 5}; | ||
|
||
// call erase | ||
j_array.erase(2); | ||
|
||
// print values | ||
std::cout << j_array << '\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 @@ | ||
[0,1,3,4,5] |
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
Oops, something went wrong.