Merge pull request #1956 from dota17/dota17-fix-typo

Fix typo in examples
pull/1991/head
Niels Lohmann 2020-03-13 17:26:24 +01:00 committed by GitHub
commit 54656ef279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 11 additions and 12 deletions

View File

@ -6,7 +6,7 @@ using json = nlohmann::json;
int main()
{
// create JSON object
json object =
const json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},

View File

@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to the first element
// get an iterator to the first element
json::iterator it = array.begin();
// serialize the element that the iterator points to

View File

@ -8,7 +8,7 @@ int main()
// create an array value
const json array = {1, 2, 3, 4, 5};
// get am iterator to the first element
// get an iterator to the first element
json::const_iterator it = array.cbegin();
// serialize the element that the iterator points to

View File

@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to one past the last element
// get an iterator to one past the last element
json::const_iterator it = array.cend();
// decrement the iterator to point to the last element

View File

@ -14,7 +14,6 @@ int main()
std::cout << std::boolalpha
<< j.contains("/number"_json_pointer) << '\n'
<< j.contains("/string"_json_pointer) << '\n'
<< j.contains("/string"_json_pointer) << '\n'
<< j.contains("/array"_json_pointer) << '\n'
<< j.contains("/array/1"_json_pointer) << '\n'
<< j.contains("/array/-"_json_pointer) << '\n'

View File

@ -8,7 +8,7 @@ int main()
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call find
// call count()
auto count_two = j_object.count("two");
auto count_three = j_object.count("three");

View File

@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to one past the last element
// get an iterator to one past the last element
json::iterator it = array.end();
// decrement the iterator to point to the last element

View File

@ -13,7 +13,7 @@ int main()
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call erase
// call erase()
j_boolean.erase(j_boolean.begin());
j_number_integer.erase(j_number_integer.begin());
j_number_float.erase(j_number_float.begin());

View File

@ -13,7 +13,7 @@ int main()
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call erase
// 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());

View File

@ -8,7 +8,7 @@ int main()
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call erase
// call erase()
auto count_one = j_object.erase("one");
auto count_three = j_object.erase("three");

View File

@ -8,7 +8,7 @@ int main()
// create a JSON array
json j_array = {0, 1, 2, 3, 4, 5};
// call erase
// call erase()
j_array.erase(2);
// print values

View File

@ -6,7 +6,7 @@ using json = nlohmann::json;
int main()
{
// create JSON array
json array = {"first", "2nd", "third", "fourth"};
const json array = {"first", "2nd", "third", "fourth"};
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';