Skip to content

Commit

Permalink
Merge branch 'nlohmann:develop' into feature/sapitskiy/spm-support
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksproger authored Oct 4, 2023
2 parents 68e0db7 + 6adae02 commit d2bb17d
Show file tree
Hide file tree
Showing 90 changed files with 227 additions and 223 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ Checks: '*,
-misc-non-private-member-variables-in-classes,
-modernize-concat-nested-namespaces,
-modernize-type-traits,
-modernize-use-constraints,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-enum-size,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JSON for Modern C++ has been originally written by Niels Lohmann.
# Since 2013 over 140 contributors have helped to improve the library.
# JSON for Modern C++ was originally written by Niels Lohmann.
# Since 2013, over 250 contributors have helped to improve the library.
# This CODEOWNERS file is only to make sure that @nlohmann is requested
# for a code review in case of a pull request.

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)

##
## PROJECT
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ pretty:
--pad-header \
--align-pointer=type \
--align-reference=type \
--add-brackets \
--add-braces \
--squeeze-lines=2 \
--convert-tabs \
--close-templates \
--lineend=linux \
Expand Down
13 changes: 6 additions & 7 deletions docs/examples/at__json_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ int main()
// output the changed array
std::cout << j["array"] << '\n';


// out_of_range.106
try
{
// try to use an array index with leading '0'
json::reference ref = j.at("/array/01"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -53,7 +52,7 @@ int main()
// try to use an array index that is not a number
json::reference ref = j.at("/array/one"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -64,7 +63,7 @@ int main()
// try to use an invalid array index
json::reference ref = j.at("/array/4"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -75,7 +74,7 @@ int main()
// try to use the array index '-'
json::reference ref = j.at("/array/-"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -86,7 +85,7 @@ int main()
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -97,7 +96,7 @@ int main()
// try to use a JSON pointer that cannot be resolved
json::reference ref = j.at("/number/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/at__json_pointer_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main()
// try to use an array index that is not a number
json::const_reference ref = j.at("/array/one"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -40,7 +40,7 @@ int main()
// try to use an invalid array index
json::const_reference ref = j.at("/array/4"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -51,7 +51,7 @@ int main()
// try to use the array index '-'
json::const_reference ref = j.at("/array/-"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -62,7 +62,7 @@ int main()
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -73,7 +73,7 @@ int main()
// try to use a JSON pointer that cannot be resolved
json::const_reference ref = j.at("/number/foo"_json_pointer);
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__keytype.c++17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ int main()
// output changed array
std::cout << object << '\n';


// exception type_error.304
try
{
// use at() with string_view on a non-object type
json str = "I am a string";
str.at("the good"sv) = "Another string";
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -43,7 +42,7 @@ int main()
// try to write at a nonexisting key using string_view
object.at("the fast"sv) = "il rapido";
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__keytype_const.c++17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ int main()
// output element with key "the ugly" using string_view
std::cout << object.at("the ugly"sv) << '\n';


// exception type_error.304
try
{
// use at() with string_view on a non-object type
const json str = "I am a string";
std::cout << str.at("the good"sv) << '\n';
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -37,7 +36,7 @@ int main()
// try to read from a nonexisting key using string_view
std::cout << object.at("the fast"sv) << '\n';
}
catch (json::out_of_range)
catch (const json::out_of_range)
{
std::cout << "out of range" << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__object_t_key_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ int main()
// output changed array
std::cout << object << '\n';


// exception type_error.304
try
{
// use at() on a non-object type
json str = "I am a string";
str.at("the good") = "Another string";
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -41,7 +40,7 @@ int main()
// try to write at a nonexisting key
object.at("the fast") = "il rapido";
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__object_t_key_type_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ int main()
// output element with key "the ugly"
std::cout << object.at("the ugly") << '\n';


// exception type_error.304
try
{
// use at() on a non-object type
const json str = "I am a string";
std::cout << str.at("the good") << '\n';
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -35,7 +34,7 @@ int main()
// try to read from a nonexisting key
std::cout << object.at("the fast") << '\n';
}
catch (json::out_of_range)
catch (const json::out_of_range)
{
std::cout << "out of range" << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__size_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ int main()
// output changed array
std::cout << array << '\n';


// exception type_error.304
try
{
// use at() on a non-array type
json str = "I am a string";
str.at(0) = "Another string";
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -36,7 +35,7 @@ int main()
// try to write beyond the array limit
array.at(5) = "sixth";
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/at__size_type_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ int main()
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';


// exception type_error.304
try
{
// use at() on a non-array type
const json str = "I am a string";
std::cout << str.at(0) << '\n';
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -30,7 +29,7 @@ int main()
// try to read beyond the array limit
std::cout << array.at(5) << '\n';
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/back.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main()
json j_null;
j_null.back();
}
catch (json::invalid_iterator& e)
catch (const json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}
Expand Down
4 changes: 0 additions & 4 deletions docs/examples/basic_json__CompatibleType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ int main()
std::cout << j_mmap << '\n';
std::cout << j_ummap << "\n\n";


// ===========
// array types
// ===========
Expand Down Expand Up @@ -117,7 +116,6 @@ int main()
std::cout << j_mset << '\n';
std::cout << j_umset << "\n\n";


// ============
// string types
// ============
Expand All @@ -138,7 +136,6 @@ int main()
std::cout << j_string_literal << '\n';
std::cout << j_stdstring << "\n\n";


// ============
// number types
// ============
Expand Down Expand Up @@ -203,7 +200,6 @@ int main()
std::cout << j_float_nan << '\n';
std::cout << j_double << "\n\n";


// =============
// boolean types
// =============
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic_json__InputIt_InputIt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main()
{
json j_invalid(j_number.begin() + 1, j_number.end());
}
catch (json::invalid_iterator& e)
catch (const json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/cbor_tag_handler_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main()
{
auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << std::endl;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/contains__json_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main()
// try to use an array index with leading '0'
j.contains("/array/01"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
Expand All @@ -36,7 +36,7 @@ int main()
// try to use an array index that is not a number
j.contains("/array/one"_json_pointer);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/diagnostics_extended.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main()
{
int housenumber = j["address"]["housenumber"];
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << e.what() << '\n';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/diagnostics_standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main()
{
int housenumber = j["address"]["housenumber"];
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << e.what() << '\n';
}
Expand Down
Loading

0 comments on commit d2bb17d

Please sign in to comment.