Merge branch 'nlohmann:develop' into develop

This commit is contained in:
Tomerkm 2023-11-10 22:51:59 +02:00 committed by GitHub
commit 0012f860e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
110 changed files with 353 additions and 288 deletions

View File

@ -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,

4
.github/CODEOWNERS vendored
View File

@ -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.

View File

@ -32,6 +32,8 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c-cpp
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)

View File

@ -31,5 +31,11 @@ jobs:
- name: Install virtual environment
run: make install_venv -C docs/mkdocs
- name: Publish documentation
run: make publish -C docs/mkdocs
- name: Build documentation
run: make build -C docs/mkdocs
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/mkdocs/site

View File

@ -29,6 +29,7 @@ jobs:
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ matrix.architecture }}
version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14
- name: Run CMake
run: cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: Build

3
.gitignore vendored
View File

@ -39,3 +39,6 @@
/localhost.pem
/localhost-key.pem
/serve_header.yml
# Swift Package Manager build directory
/.build

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)
##
## PROJECT
@ -122,7 +122,7 @@ target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}>
)
## add debug view definition file for msvc (natvis)

View File

@ -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 \

22
Package.swift Normal file
View File

@ -0,0 +1,22 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "nlohmann-json",
platforms: [
.iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4)
],
products: [
.library(name: "json", targets: ["json"])
],
targets: [
.target(
name: "json",
path: "single_include/nlohmann",
publicHeadersPath: "."
)
],
cxxLanguageStandard: .cxx11
)

View File

@ -1338,6 +1338,8 @@ If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install
If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open).
If you are using [Swift Package Manager](https://swift.org/package-manager/), you can use the library by adding a package dependency to this repository. And target dependency as `.product(name: "nlohmann-json", package: "json")`.
If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues).
If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues).

View File

@ -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';
}
@ -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';
}
@ -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';
}
@ -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';
}
@ -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';
}
@ -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';
}

View File

@ -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';
}
@ -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';
}
@ -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';
}
@ -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';
}
@ -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';
}

View File

@ -24,7 +24,6 @@ int main()
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
@ -32,7 +31,7 @@ int main()
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';
}
@ -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';
}

View File

@ -18,7 +18,6 @@ int main()
// output element with key "the ugly" using string_view
std::cout << object.at("the ugly"sv) << '\n';
// exception type_error.304
try
{
@ -26,7 +25,7 @@ int main()
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';
}
@ -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';
}

View File

@ -22,7 +22,6 @@ int main()
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
@ -30,7 +29,7 @@ int main()
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';
}
@ -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';
}

View File

@ -16,7 +16,6 @@ int main()
// output element with key "the ugly"
std::cout << object.at("the ugly") << '\n';
// exception type_error.304
try
{
@ -24,7 +23,7 @@ int main()
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';
}
@ -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';
}

View File

@ -17,7 +17,6 @@ int main()
// output changed array
std::cout << array << '\n';
// exception type_error.304
try
{
@ -25,7 +24,7 @@ int main()
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';
}
@ -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';
}

View File

@ -11,7 +11,6 @@ int main()
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';
// exception type_error.304
try
{
@ -19,7 +18,7 @@ int main()
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';
}
@ -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';
}

View File

@ -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';
}

View File

@ -55,7 +55,6 @@ int main()
std::cout << j_mmap << '\n';
std::cout << j_ummap << "\n\n";
// ===========
// array types
// ===========
@ -117,7 +116,6 @@ int main()
std::cout << j_mset << '\n';
std::cout << j_umset << "\n\n";
// ============
// string types
// ============
@ -138,7 +136,6 @@ int main()
std::cout << j_string_literal << '\n';
std::cout << j_stdstring << "\n\n";
// ============
// number types
// ============
@ -203,7 +200,6 @@ int main()
std::cout << j_float_nan << '\n';
std::cout << j_double << "\n\n";
// =============
// boolean types
// =============

View File

@ -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';
}

View File

@ -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;
}

View File

@ -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';
}
@ -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';
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -35,7 +35,7 @@ int main()
{
std::cout << j_invalid.dump() << std::endl;
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@ -11,7 +11,7 @@ int main()
{
std::cout << j_invalid.dump() << std::endl;
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@ -11,7 +11,7 @@ int main()
json j = {{"foo", "bar"}};
json k = j.at("non-existing");
}
catch (json::exception& e)
catch (const json::exception& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -20,7 +20,7 @@ int main()
{
auto r3 = value.get_ref<json::number_float_t&>();
}
catch (json::type_error& ex)
catch (const json::type_error& ex)
{
std::cout << ex.what() << '\n';
}

View File

@ -30,7 +30,6 @@ int main()
std::vector<short> v7;
std::unordered_map<std::string, json> v8;
// use explicit conversions
json_types["boolean"].get_to(v1);
json_types["number"]["integer"].get_to(v2);

View File

@ -12,7 +12,7 @@ int main()
json::iterator it = j.begin();
auto k = it.key();
}
catch (json::invalid_iterator& e)
catch (const json::invalid_iterator& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -20,7 +20,7 @@ int main()
{
json::json_pointer p9("foo");
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@ -30,7 +30,7 @@ int main()
{
json::json_pointer p10("/foo/~");
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@ -40,7 +40,7 @@ int main()
{
json::json_pointer p11("/foo/~3");
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}

View File

@ -53,7 +53,7 @@ int main()
{
auto p3 = j3.template get<ns::person>();
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@ -41,7 +41,7 @@ int main()
{
auto p3 = j3.template get<ns::person>();
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@ -46,7 +46,7 @@ int main()
{
auto p3 = j3.template get<ns::person>();
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@ -34,7 +34,7 @@ int main()
{
auto p3 = j3.template get<ns::person>();
}
catch (json::exception& e)
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@ -21,7 +21,7 @@ int main()
// can only create an object from a list of pairs
json j_invalid_object = json::object({{ "one", 1, 2 }});
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}

View File

@ -53,7 +53,7 @@ int main()
{
bool v1 = json_types["string"];
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}

View File

@ -32,7 +32,6 @@ int main()
json string = "foo";
json discarded = json(json::value_t::discarded);
// output values and comparisons
std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD*
std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD*

View File

@ -31,7 +31,6 @@ int main()
json number = 17;
json string = "17";
// output values and comparisons
std::cout << std::boolalpha << std::fixed;
std::cout << boolean << " <=> " << true << " := " << to_string(boolean <=> true) << '\n'; // *NOPAD*

View File

@ -21,7 +21,7 @@ int main()
}])"_json;
value.patch(patch);
}
catch (json::other_error& e)
catch (const json::other_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -11,7 +11,7 @@ int main()
json j = {1, 2, 3, 4};
j.at(4) = 10;
}
catch (json::out_of_range& e)
catch (const json::out_of_range& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -17,7 +17,7 @@ int main()
{
json j = json::parse(text);
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@ -33,7 +33,6 @@ int main()
json j_complete = json::parse(ss);
std::cout << std::setw(4) << j_complete << "\n\n";
// define parser callback
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
{

View File

@ -28,7 +28,6 @@ int main()
json j_complete = json::parse(text);
std::cout << std::setw(4) << j_complete << "\n\n";
// define parser callback
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
{

View File

@ -10,7 +10,7 @@ int main()
// parsing input with a syntax error
json::parse("[1,2,3,]");
}
catch (json::parse_error& e)
catch (const json::parse_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -11,7 +11,7 @@ int main()
json j = "string";
j.push_back("another string");
}
catch (json::type_error& e)
catch (const json::type_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@ -21,7 +21,7 @@ style_check:
clean:
rm -fr docs/images/json.gif docs/examples
# publish site to GitHub pages
# publish site to GitHub pages (not working in GitHub Actions; need special action)
publish: prepare_files
venv/bin/mkdocs gh-deploy --clean --force

View File

@ -14,7 +14,7 @@ noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
```
This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json)
This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json/index.md)
class (either explicitly or via the conversion operators).
1. This function is chosen for default-constructible value types.

View File

@ -7,7 +7,7 @@ static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
```
This function is usually called by the constructors of the [basic_json](../basic_json) class.
This function is usually called by the constructors of the [basic_json](../basic_json/index.md) class.
## Parameters

View File

@ -68,7 +68,7 @@ constructor.
## See also
[List of exceptions](127.0.0.1:8000/home/exceptions/)
[List of exceptions](../../home/exceptions.md)
## Version history

View File

@ -13,8 +13,8 @@ template<
class NumberFloatType = double,
template<typename U> class AllocatorType = std::allocator,
template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer,
class BinaryType = std::vector<std::uint8_t,
class CustomBaseClass = void>
class BinaryType = std::vector<std::uint8_t>,
class CustomBaseClass = void
>
class basic_json;
```
@ -73,7 +73,7 @@ The class satisfies the following concept requirements:
- [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): JSON values can be compared with
`==`, see [`operator==`](operator_eq.md).
- [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): JSON values can be compared with
`<`, see [`operator<`](operator_le).
`<`, see [`operator<`](operator_le.md).
- [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): Any JSON lvalue or rvalue of can be swapped with
any lvalue or rvalue of other compatible types, using unqualified function `swap`.
- [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): JSON values can be compared against
@ -88,7 +88,7 @@ The class satisfies the following concept requirements:
## Member types
- [**adl_serializer**](../adl_serializer) - the default serializer
- [**adl_serializer**](../adl_serializer/index.md) - the default serializer
- [**value_t**](value_t.md) - the JSON type enumeration
- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON

View File

@ -17,7 +17,7 @@ using json_serializer = JSONSerializer<T, SFINAE>;
#### Default type
The default values for `json_serializer` is [`adl_serializer`](../adl_serializer).
The default values for `json_serializer` is [`adl_serializer`](../adl_serializer/index.md).
## Examples

View File

@ -0,0 +1,31 @@
# JSON_HAS_STATIC_RTTI
```cpp
#define JSON_HAS_STATIC_RTTI /* value */
```
This macro indicates whether the standard library has any support for RTTI (run time type information).
Possible values are `1` when supported or `0` when unsupported.
## Default definition
The default value is detected based on the preprocessor macro `#!cpp _HAS_STATIC_RTTI`.
When the macro is not defined, the library will define it to its default value.
## Examples
??? example
The code below forces the library to enable support for libraries with RTTI dependence:
```cpp
#define JSON_HAS_STATIC_RTTI 1
#include <nlohmann/json.hpp>
...
```
## Version history
- Added in version ?.

View File

@ -68,7 +68,7 @@ replaced by calling [`std::abort`](https://en.cppreference.com/w/cpp/utility/pro
## See also
- [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions
- [JSON_NOEXCEPTION](JSON_NOEXCEPTION) - switch off exceptions
- [JSON_NOEXCEPTION](json_noexception.md) - switch off exceptions
## Version history

View File

@ -59,7 +59,7 @@ See examples below for the concrete generated code.
Consider the following complete example:
```cpp hl_lines="21"
```cpp hl_lines="22"
--8<-- "examples/nlohmann_define_type_intrusive_macro.cpp"
```
@ -80,7 +80,7 @@ See examples below for the concrete generated code.
The macro is equivalent to:
```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33"
```cpp hl_lines="22 23 24 25 26 27 28 29 30 31 32 33 34"
--8<-- "examples/nlohmann_define_type_intrusive_explicit.cpp"
```
@ -88,7 +88,7 @@ See examples below for the concrete generated code.
Consider the following complete example:
```cpp hl_lines="21"
```cpp hl_lines="22"
--8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.cpp"
```
@ -108,7 +108,7 @@ See examples below for the concrete generated code.
The macro is equivalent to:
```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34"
```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34 35"
--8<-- "examples/nlohmann_define_type_intrusive_with_default_explicit.cpp"
```

View File

@ -60,7 +60,7 @@ See examples below for the concrete generated code.
Consider the following complete example:
```cpp hl_lines="15"
```cpp hl_lines="16"
--8<-- "examples/nlohmann_define_type_non_intrusive_macro.cpp"
```
@ -80,7 +80,7 @@ See examples below for the concrete generated code.
The macro is equivalent to:
```cpp hl_lines="15 16 17 18 19 20 21 22 23 24 25 26 27"
```cpp hl_lines="16 17 18 19 20 21 22 23 24 25 26 27 28"
--8<-- "examples/nlohmann_define_type_non_intrusive_explicit.cpp"
```
@ -88,7 +88,7 @@ See examples below for the concrete generated code.
Consider the following complete example:
```cpp hl_lines="20"
```cpp hl_lines="21"
--8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp"
```
@ -109,7 +109,7 @@ See examples below for the concrete generated code.
The macro is equivalent to:
```cpp hl_lines="20 21 22 23 24 25 26 27 28 29 30 31 32 33"
```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34"
--8<-- "examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp"
```

View File

@ -1,7 +1,7 @@
# <small>nlohmann::</small>operator""_json
```cpp
json operator "" _json(const char* s, std::size_t n);
json operator ""_json(const char* s, std::size_t n);
```
This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a
@ -9,7 +9,7 @@ string literal and returns a [`json`](json.md) object if no parse error occurred
It is recommended to bring the operator into scope using any of the following lines:
```cpp
using nlohmann::literals::operator "" _json;
using nlohmann::literals::operator ""_json;
using namespace nlohmann::literals;
using namespace nlohmann::json_literals;
using namespace nlohmann::literals::json_literals;

View File

@ -1,7 +1,7 @@
# <small>nlohmann::</small>operator""_json_pointer
```cpp
json_pointer operator "" _json_pointer(const char* s, std::size_t n);
json_pointer operator ""_json_pointer(const char* s, std::size_t n);
```
This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer`
@ -9,7 +9,7 @@ to a string literal and returns a [`json_pointer`](json_pointer/index.md) object
It is recommended to bring the operator into scope using any of the following lines:
```cpp
using nlohmann::literals::operator "" _json_pointer;
using nlohmann::literals::operator ""_json_pointer;
using namespace nlohmann::literals;
using namespace nlohmann::json_literals;
using namespace nlohmann::literals::json_literals;

View File

@ -245,7 +245,7 @@ integers, and between integers and floating-point values to integers. This beha
The rationale is twofold:
1. JSON does not define a number type or precision (see [#json-specification](above)).
1. JSON does not define a number type or precision (see above).
2. C++ also allows to silently convert between number types.
!!! success "Conditional number conversion"

View File

@ -139,7 +139,7 @@ This error indicates a syntax error while deserializing a JSON text. The error m
No input:
```
[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal
[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON
```
Control character was not escaped:

View File

@ -9,7 +9,7 @@ Throughout this page, we will describe how to compile the example file `example.
When executed, this program should create output similar to
```json
--8<-- "../../examples/meta.output"
--8<-- "examples/meta.output"
```
## Homebrew

View File

@ -9,7 +9,7 @@ repo_url: https://github.com/nlohmann/json
edit_uri: edit/develop/docs/mkdocs/docs
# Copyright
copyright: Copyright &copy; 2013 - 2022 Niels Lohmann
copyright: Copyright &copy; 2013 - 2023 Niels Lohmann
# Configuration
theme:
@ -270,6 +270,7 @@ nav:
- 'JSON_HAS_EXPERIMENTAL_FILESYSTEM': api/macros/json_has_filesystem.md
- 'JSON_HAS_FILESYSTEM': api/macros/json_has_filesystem.md
- 'JSON_HAS_RANGES': api/macros/json_has_ranges.md
- 'JSON_HAS_STATIC_RTTI': api/macros/json_has_static_rtti.md
- 'JSON_HAS_THREE_WAY_COMPARISON': api/macros/json_has_three_way_comparison.md
- 'JSON_NOEXCEPTION': api/macros/json_noexception.md
- 'JSON_NO_IO': api/macros/json_no_io.md
@ -325,8 +326,8 @@ markdown_extensions:
- pymdownx.critic
- pymdownx.details
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.inlinehilite
- pymdownx.magiclink
- pymdownx.mark

View File

@ -1,49 +1,49 @@
Babel==2.11.0
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
Babel==2.13.1
certifi==2023.7.22
charset-normalizer==3.3.1
click==8.1.7
csscompressor==0.9.5
future==0.18.3
ghp-import==2.1.0
gitdb==4.0.10
GitPython==3.1.29
gitdb==4.0.11
GitPython==3.1.40
htmlmin==0.1.12
httplib2==0.21.0
httplib2==0.22.0
idna==3.4
importlib-metadata==5.1.0
importlib-metadata==6.8.0
Jinja2==3.1.2
joblib==1.2.0
joblib==1.3.2
jsmin==3.0.1
livereload==2.6.3
lunr==0.6.2
Markdown==3.3.7 # we cannot install a more recent version yet as mkdocs 1.4.2 depends on markdown<3.4
markdown-include==0.8.0
MarkupSafe==2.1.1
lunr==0.7.0.post1
Markdown==3.5
markdown-include==0.8.1
MarkupSafe==2.1.3
mergedeep==1.3.4
mkdocs==1.4.2
mkdocs-git-revision-date-localized-plugin==1.1.0
mkdocs-material==8.5.11
mkdocs-material-extensions==1.1.1
mkdocs-minify-plugin==0.6.2
mkdocs-redirects==1.2.0
mkdocs==1.5.3
mkdocs-git-revision-date-localized-plugin==1.2.1
mkdocs-material==9.4.7
mkdocs-material-extensions==1.3
mkdocs-minify-plugin==0.7.1
mkdocs-redirects==1.2.1
mkdocs-simple-hooks==0.1.5
nltk==3.8
packaging==22.0
nltk==3.8.1
packaging==23.2
plantuml==0.3.0
plantuml-markdown==3.7.3
Pygments==2.13.0
pymdown-extensions==9.9
pyparsing==3.0.9
plantuml-markdown==3.9.2
Pygments==2.16.1
pymdown-extensions==10.3.1
pyparsing==3.1.1
python-dateutil==2.8.2
pytz==2022.7
PyYAML==6.0
pytz==2023.3.post1
PyYAML==6.0.1
pyyaml_env_tag==0.1
regex==2022.10.31
requests==2.28.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
smmap==5.0.0
tornado==6.2
tqdm==4.64.1
urllib3==1.26.13
watchdog==2.2.0
zipp==3.11.0
smmap==5.0.1
tornado==6.3.3
tqdm==4.66.1
urllib3==2.0.7
watchdog==3.0.0
zipp==3.17.0

View File

@ -25,7 +25,6 @@
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/string_concat.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{

View File

@ -55,7 +55,6 @@ static inline bool little_endianness(int num = 1) noexcept
return *reinterpret_cast<char*>(&num) == 1;
}
///////////////////
// binary reader //
///////////////////

View File

@ -71,7 +71,6 @@ class file_input_adapter
std::FILE* m_file;
};
/*!
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
beginning of input. Does not support changing the underlying std::streambuf
@ -170,7 +169,6 @@ class iterator_input_adapter
}
};
template<typename BaseInputAdapter, size_t T>
struct wide_string_input_helper;
@ -294,7 +292,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
}
};
// Wraps another input apdater to convert wide character types into individual bytes.
// Wraps another input adapter to convert wide character types into individual bytes.
template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter
{
@ -339,7 +337,6 @@ class wide_string_input_adapter
std::size_t utf8_bytes_filled = 0;
};
template<typename IteratorType, typename Enable = void>
struct iterator_input_adapter_factory
{

View File

@ -142,7 +142,6 @@ struct json_sax
virtual ~json_sax() = default;
};
namespace detail
{
/*!
@ -591,7 +590,7 @@ class json_sax_dom_callback_parser
if (ref_stack.empty())
{
root = std::move(value);
return {true, &root};
return {true, & root};
}
// skip this value if we already decided to skip the parent
@ -608,7 +607,7 @@ class json_sax_dom_callback_parser
if (ref_stack.back()->is_array())
{
ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
return {true, &(ref_stack.back()->m_data.m_value.array->back())};
return {true, & (ref_stack.back()->m_data.m_value.array->back())};
}
// object

View File

@ -222,7 +222,7 @@ class lexer : public lexer_base<BasicJsonType>
for (auto range = ranges.begin(); range != ranges.end(); ++range)
{
get();
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions)
{
add(current);
}

View File

@ -341,13 +341,25 @@ class parser
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
}
case token_type::end_of_input:
{
if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1))
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
"attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
}
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr));
}
case token_type::uninitialized:
case token_type::end_array:
case token_type::end_object:
case token_type::name_separator:
case token_type::value_separator:
case token_type::end_of_input:
case token_type::literal_or_value:
default: // the last token was unexpected
{

View File

@ -69,10 +69,10 @@ template<typename IteratorType> class iteration_proxy_value
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
iteration_proxy_value(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_constructible<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
~iteration_proxy_value() = default;
/// dereference operator (needed for range-based for)

View File

@ -133,6 +133,14 @@
#endif
#endif
#ifndef JSON_HAS_STATIC_RTTI
#if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
#define JSON_HAS_STATIC_RTTI 1
#else
#define JSON_HAS_STATIC_RTTI 0
#endif
#endif
#ifdef JSON_HAS_CPP_17
#define JSON_INLINE_VARIABLE inline
#else
@ -411,7 +419,6 @@
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
// inspired from https://stackoverflow.com/a/26745591
// allows to call any std function as if (e.g. with begin):
// using std::begin; begin(x);

View File

@ -38,6 +38,7 @@
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
#undef JSON_HAS_THREE_WAY_COMPARISON
#undef JSON_HAS_RANGES
#undef JSON_HAS_STATIC_RTTI
#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#endif

View File

@ -217,7 +217,6 @@ template <typename... Ts>
struct is_default_constructible<const std::tuple<Ts...>>
: conjunction<is_default_constructible<Ts>...> {};
template <typename T, typename... Args>
struct is_constructible : std::is_constructible<T, Args...> {};
@ -233,7 +232,6 @@ struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple
template <typename... Ts>
struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
template<typename T, typename = void>
struct is_iterator_traits : std::false_type {};
@ -643,7 +641,6 @@ struct value_in_range_of_impl2<OfType, T, false, true>
}
};
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, true, true>
{

View File

@ -62,7 +62,9 @@
#include <nlohmann/ordered_map.hpp>
#if defined(JSON_HAS_CPP_17)
#include <any>
#if JSON_HAS_STATIC_RTTI
#include <any>
#endif
#include <string_view>
#endif
@ -192,7 +194,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
/////////////////////
// container types //
/////////////////////
@ -234,7 +235,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
/// @brief returns the allocator associated with the container
/// @sa https://json.nlohmann.me/api/basic_json/get_allocator/
static allocator_type get_allocator()
@ -297,7 +297,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
#endif
#if defined(_MSVC_LANG)
result["compiler"]["c++"] = std::to_string(_MSVC_LANG);
#elif defined(__cplusplus)
@ -308,7 +307,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return result;
}
///////////////////////////
// JSON value data types //
///////////////////////////
@ -910,7 +908,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
bool is_an_object = std::all_of(init.begin(), init.end(),
[](const detail::json_ref<basic_json>& element_ref)
{
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
// The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int;
// (many string types can be constructed from 0 via its null-pointer guise, so we get a
// broken call to op[key_type], the wrong semantics and a 4804 warning on Windows)
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
});
// adjust type if type deduction is not wanted
@ -1130,7 +1131,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
assert_invariant();
}
///////////////////////////////////////
// other constructors and destructor //
///////////////////////////////////////
@ -1888,7 +1888,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
detail::negation<std::is_same<ValueType, std::string_view>>,
#endif
#if defined(JSON_HAS_CPP_17)
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
detail::negation<std::is_same<ValueType, std::any>>,
#endif
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
@ -1925,7 +1925,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
////////////////////
// element access //
////////////////////
@ -2640,7 +2639,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
////////////
// lookup //
////////////
@ -2758,7 +2756,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
///////////////
// iterators //
///////////////
@ -2897,7 +2894,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
//////////////
// capacity //
//////////////
@ -3019,7 +3015,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
///////////////
// modifiers //
///////////////
@ -3467,7 +3462,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
void swap(reference other) noexcept (
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
std::is_nothrow_move_assignable<json_value>::value
)
{
@ -3484,7 +3479,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
friend void swap(reference left, reference right) noexcept (
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
std::is_nothrow_move_assignable<json_value>::value
)
{
@ -3493,7 +3488,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(array_t& other) // NOLINT(bugprone-exception-escape)
void swap(array_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for arrays
if (JSON_HEDLEY_LIKELY(is_array()))
@ -3509,7 +3504,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(object_t& other) // NOLINT(bugprone-exception-escape)
void swap(object_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
@ -3525,7 +3520,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(string_t& other) // NOLINT(bugprone-exception-escape)
void swap(string_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_string()))
@ -3541,7 +3536,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(binary_t& other) // NOLINT(bugprone-exception-escape)
void swap(binary_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_binary()))
@ -4006,7 +4001,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#endif // JSON_NO_IO
/// @}
/////////////////////
// deserialization //
/////////////////////
@ -4187,7 +4181,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
}
JSON_PRIVATE_UNLESS_TESTED:
//////////////////////
// member variables //
@ -4405,7 +4398,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
static basic_json from_cbor(detail::span_input_adapter&& i,
@ -4529,7 +4521,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return res ? result : basic_json(value_t::discarded);
}
/// @brief create a JSON value from an input in BJData format
/// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/
template<typename InputType>
@ -4810,7 +4801,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
};
// wrapper for "remove" operation; remove value at ptr
const auto operation_remove = [this, &result](json_pointer & ptr)
const auto operation_remove = [this, & result](json_pointer & ptr)
{
// get reference to parent of JSON pointer ptr
const auto last_path = ptr.back();
@ -5173,7 +5164,11 @@ inline namespace json_literals
/// @brief user-defined string literal for JSON values
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/
JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
inline nlohmann::json operator ""_json(const char* s, std::size_t n)
#else
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
#endif
{
return nlohmann::json::parse(s, s + n);
}
@ -5181,7 +5176,11 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t n)
/// @brief user-defined string literal for JSON pointer
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/
JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n)
#else
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
#endif
{
return nlohmann::json::json_pointer(std::string(s, n));
}
@ -5234,7 +5233,7 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<',
/// @sa https://json.nlohmann.me/api/basic_json/std_swap/
NLOHMANN_BASIC_JSON_TPL_DECLARATION
inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp)
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&& // NOLINT(misc-redundant-expression)
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&& // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
{
j1.swap(j2);
@ -5245,8 +5244,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
} // namespace std
#if JSON_USE_GLOBAL_UDLS
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#else
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#endif
#endif
#include <nlohmann/detail/macro_unscope.hpp>

View File

@ -2485,6 +2485,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#endif
#endif
#ifndef JSON_HAS_STATIC_RTTI
#if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
#define JSON_HAS_STATIC_RTTI 1
#else
#define JSON_HAS_STATIC_RTTI 0
#endif
#endif
#ifdef JSON_HAS_CPP_17
#define JSON_INLINE_VARIABLE inline
#else
@ -2763,7 +2771,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
// inspired from https://stackoverflow.com/a/26745591
// allows to call any std function as if (e.g. with begin):
// using std::begin; begin(x);
@ -3617,7 +3624,6 @@ template <typename... Ts>
struct is_default_constructible<const std::tuple<Ts...>>
: conjunction<is_default_constructible<Ts>...> {};
template <typename T, typename... Args>
struct is_constructible : std::is_constructible<T, Args...> {};
@ -3633,7 +3639,6 @@ struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple
template <typename... Ts>
struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
template<typename T, typename = void>
struct is_iterator_traits : std::false_type {};
@ -4043,7 +4048,6 @@ struct value_in_range_of_impl2<OfType, T, false, true>
}
};
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, true, true>
{
@ -4290,7 +4294,6 @@ inline OutStringType concat(Args && ... args)
NLOHMANN_JSON_NAMESPACE_END
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@ -5151,10 +5154,10 @@ template<typename IteratorType> class iteration_proxy_value
// older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
iteration_proxy_value(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_constructible<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor,cppcoreguidelines-noexcept-move-operations)
~iteration_proxy_value() = default;
/// dereference operator (needed for range-based for)
@ -6144,7 +6147,6 @@ class file_input_adapter
std::FILE* m_file;
};
/*!
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
beginning of input. Does not support changing the underlying std::streambuf
@ -6243,7 +6245,6 @@ class iterator_input_adapter
}
};
template<typename BaseInputAdapter, size_t T>
struct wide_string_input_helper;
@ -6367,7 +6368,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
}
};
// Wraps another input apdater to convert wide character types into individual bytes.
// Wraps another input adapter to convert wide character types into individual bytes.
template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter
{
@ -6412,7 +6413,6 @@ class wide_string_input_adapter
std::size_t utf8_bytes_filled = 0;
};
template<typename IteratorType, typename Enable = void>
struct iterator_input_adapter_factory
{
@ -6714,7 +6714,6 @@ struct json_sax
virtual ~json_sax() = default;
};
namespace detail
{
/*!
@ -7163,7 +7162,7 @@ class json_sax_dom_callback_parser
if (ref_stack.empty())
{
root = std::move(value);
return {true, &root};
return {true, & root};
}
// skip this value if we already decided to skip the parent
@ -7180,7 +7179,7 @@ class json_sax_dom_callback_parser
if (ref_stack.back()->is_array())
{
ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
return {true, &(ref_stack.back()->m_data.m_value.array->back())};
return {true, & (ref_stack.back()->m_data.m_value.array->back())};
}
// object
@ -7527,7 +7526,7 @@ class lexer : public lexer_base<BasicJsonType>
for (auto range = ranges.begin(); range != ranges.end(); ++range)
{
get();
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions)
{
add(current);
}
@ -9133,7 +9132,6 @@ static inline bool little_endianness(int num = 1) noexcept
return *reinterpret_cast<char*>(&num) == 1;
}
///////////////////
// binary reader //
///////////////////
@ -12443,13 +12441,25 @@ class parser
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
}
case token_type::end_of_input:
{
if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1))
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
"attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
}
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr));
}
case token_type::uninitialized:
case token_type::end_array:
case token_type::end_object:
case token_type::name_separator:
case token_type::value_separator:
case token_type::end_of_input:
case token_type::literal_or_value:
default: // the last token was unexpected
{
@ -19278,7 +19288,9 @@ NLOHMANN_JSON_NAMESPACE_END
#if defined(JSON_HAS_CPP_17)
#include <any>
#if JSON_HAS_STATIC_RTTI
#include <any>
#endif
#include <string_view>
#endif
@ -19408,7 +19420,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
/////////////////////
// container types //
/////////////////////
@ -19450,7 +19461,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
/// @brief returns the allocator associated with the container
/// @sa https://json.nlohmann.me/api/basic_json/get_allocator/
static allocator_type get_allocator()
@ -19513,7 +19523,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
#endif
#if defined(_MSVC_LANG)
result["compiler"]["c++"] = std::to_string(_MSVC_LANG);
#elif defined(__cplusplus)
@ -19524,7 +19533,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return result;
}
///////////////////////////
// JSON value data types //
///////////////////////////
@ -20126,7 +20134,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
bool is_an_object = std::all_of(init.begin(), init.end(),
[](const detail::json_ref<basic_json>& element_ref)
{
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
// The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int;
// (many string types can be constructed from 0 via its null-pointer guise, so we get a
// broken call to op[key_type], the wrong semantics and a 4804 warning on Windows)
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
});
// adjust type if type deduction is not wanted
@ -20346,7 +20357,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
assert_invariant();
}
///////////////////////////////////////
// other constructors and destructor //
///////////////////////////////////////
@ -21104,7 +21114,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
detail::negation<std::is_same<ValueType, std::string_view>>,
#endif
#if defined(JSON_HAS_CPP_17)
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
detail::negation<std::is_same<ValueType, std::any>>,
#endif
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
@ -21141,7 +21151,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
////////////////////
// element access //
////////////////////
@ -21856,7 +21865,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
////////////
// lookup //
////////////
@ -21974,7 +21982,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
///////////////
// iterators //
///////////////
@ -22113,7 +22120,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
//////////////
// capacity //
//////////////
@ -22235,7 +22241,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @}
///////////////
// modifiers //
///////////////
@ -22683,7 +22688,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
void swap(reference other) noexcept (
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
std::is_nothrow_move_assignable<json_value>::value
)
{
@ -22700,7 +22705,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
friend void swap(reference left, reference right) noexcept (
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_constructible<json_value>::value&& // NOLINT(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
std::is_nothrow_move_assignable<json_value>::value
)
{
@ -22709,7 +22714,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(array_t& other) // NOLINT(bugprone-exception-escape)
void swap(array_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for arrays
if (JSON_HEDLEY_LIKELY(is_array()))
@ -22725,7 +22730,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(object_t& other) // NOLINT(bugprone-exception-escape)
void swap(object_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for objects
if (JSON_HEDLEY_LIKELY(is_object()))
@ -22741,7 +22746,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(string_t& other) // NOLINT(bugprone-exception-escape)
void swap(string_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_string()))
@ -22757,7 +22762,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief exchanges the values
/// @sa https://json.nlohmann.me/api/basic_json/swap/
void swap(binary_t& other) // NOLINT(bugprone-exception-escape)
void swap(binary_t& other) // NOLINT(bugprone-exception-escape,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_binary()))
@ -23222,7 +23227,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
#endif // JSON_NO_IO
/// @}
/////////////////////
// deserialization //
/////////////////////
@ -23403,7 +23407,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
}
JSON_PRIVATE_UNLESS_TESTED:
//////////////////////
// member variables //
@ -23621,7 +23624,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
static basic_json from_cbor(detail::span_input_adapter&& i,
@ -23745,7 +23747,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return res ? result : basic_json(value_t::discarded);
}
/// @brief create a JSON value from an input in BJData format
/// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/
template<typename InputType>
@ -24026,7 +24027,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
};
// wrapper for "remove" operation; remove value at ptr
const auto operation_remove = [this, &result](json_pointer & ptr)
const auto operation_remove = [this, & result](json_pointer & ptr)
{
// get reference to parent of JSON pointer ptr
const auto last_path = ptr.back();
@ -24389,7 +24390,11 @@ inline namespace json_literals
/// @brief user-defined string literal for JSON values
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/
JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
inline nlohmann::json operator ""_json(const char* s, std::size_t n)
#else
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
#endif
{
return nlohmann::json::parse(s, s + n);
}
@ -24397,7 +24402,11 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t n)
/// @brief user-defined string literal for JSON pointer
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/
JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n)
#else
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
#endif
{
return nlohmann::json::json_pointer(std::string(s, n));
}
@ -24450,7 +24459,7 @@ struct less< ::nlohmann::detail::value_t> // do not remove the space after '<',
/// @sa https://json.nlohmann.me/api/basic_json/std_swap/
NLOHMANN_BASIC_JSON_TPL_DECLARATION
inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp)
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&& // NOLINT(misc-redundant-expression)
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&& // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
{
j1.swap(j2);
@ -24461,8 +24470,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
} // namespace std
#if JSON_USE_GLOBAL_UDLS
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#else
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
#endif
#endif
// #include <nlohmann/detail/macro_unscope.hpp>
@ -24506,6 +24520,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
#undef JSON_HAS_THREE_WAY_COMPARISON
#undef JSON_HAS_RANGES
#undef JSON_HAS_STATIC_RTTI
#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#endif

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.13...3.14)
option(JSON_Valgrind "Execute test suite with Valgrind." OFF)
option(JSON_FastTests "Skip expensive/slow tests." OFF)

View File

@ -5491,7 +5491,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
}
};
// Wraps another input apdater to convert wide character types into individual bytes.
// Wraps another input adapter to convert wide character types into individual bytes.
template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter
{

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.11...3.14)
project(JSON_Benchmarks LANGUAGES CXX)
# set compiler flags

View File

@ -81,7 +81,6 @@ BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regressi
BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
//////////////////////////////////////////////////////////////////////////////
// serialize JSON
//////////////////////////////////////////////////////////////////////////////
@ -116,7 +115,6 @@ BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4);
//////////////////////////////////////////////////////////////////////////////
// serialize CBOR
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)
project(DummyImport CXX)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.11...3.14)
project(DummyImport CXX)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)
project(DummyImport CXX)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)
project(DummyImportMinVer CXX)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1...3.14)
project(DummyImport CXX)

View File

@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
// step 2.1: round trip without adding size annotations to container types
std::vector<uint8_t> const vec2 = json::to_bjdata(j1, false, false);
// step 2.2: round trip with adding size annotations but without adding type annonations to container types
// step 2.2: round trip with adding size annotations but without adding type annotations to container types
std::vector<uint8_t> const vec3 = json::to_bjdata(j1, true, false);
// step 2.3: round trip with adding size as well as type annotations to container types

View File

@ -45,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
// step 2.1: round trip without adding size annotations to container types
std::vector<uint8_t> const vec2 = json::to_ubjson(j1, false, false);
// step 2.2: round trip with adding size annotations but without adding type annonations to container types
// step 2.2: round trip with adding size annotations but without adding type annotations to container types
std::vector<uint8_t> const vec3 = json::to_ubjson(j1, true, false);
// step 2.3: round trip with adding size as well as type annotations to container types

View File

@ -14,7 +14,6 @@ using nlohmann::json;
#include <climits> // SIZE_MAX
#include <limits> // numeric_limits
template <typename OfType, typename T, bool MinInRange, bool MaxInRange>
struct trait_test_arg
{
@ -88,7 +87,6 @@ TEST_CASE_TEMPLATE_DEFINE("value_in_range_of trait", T, value_in_range_of_test)
}
}
TEST_CASE("32bit")
{
REQUIRE(SIZE_MAX == 0xffffffff);

View File

@ -319,7 +319,6 @@ TEST_CASE("algorithms")
}
}
SECTION("copy")
{
SECTION("copy without if")
@ -336,7 +335,6 @@ TEST_CASE("algorithms")
json dest_arr;
const json source_arr = {0, 3, 6, 9, 12, 15, 20};
std::copy_if(source_arr.begin(), source_arr.end(), std::back_inserter(dest_arr), [](const json & _value)
{
return _value.get<int>() % 3 == 0;
@ -364,6 +362,4 @@ TEST_CASE("algorithms")
}
}
}

View File

@ -14,7 +14,6 @@
#include <string>
#include <utility>
/* forward declarations */
class alt_string;
bool operator<(const char* op1, const alt_string& op2) noexcept;
@ -180,7 +179,6 @@ using alt_json = nlohmann::basic_json <
std::allocator,
nlohmann::adl_serializer >;
bool operator<(const char* op1, const alt_string& op2) noexcept
{
return op1 < op2.str_impl;

View File

@ -1499,7 +1499,6 @@ TEST_CASE("BJData")
}
}
SECTION("binary")
{
SECTION("N = 0..127")

View File

@ -562,7 +562,7 @@ TEST_CASE("BSON")
}
}
SECTION("Examples from http://bsonspec.org/faq.html")
SECTION("Examples from https://bsonspec.org/faq.html")
{
SECTION("Example 1")
{
@ -919,7 +919,6 @@ TEST_CASE("BSON numerical data")
}
}
SECTION("signed std::int32_t: INT32_MIN .. INT32_MAX")
{
std::vector<int32_t> const numbers

View File

@ -1962,7 +1962,7 @@ TEST_CASE("CBOR regressions")
CHECK(false);
}
}
catch (const json::parse_error&)
catch (const json::parse_error&) // NOLINT(bugprone-empty-catch)
{
// parse errors are ok, because input may be random bytes
}

View File

@ -542,13 +542,13 @@ TEST_CASE("parser class")
CHECK(parser_helper("9007199254740991").get<int64_t>() == 9007199254740991);
}
SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers)
SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers)
{
// While RFC8259, Section 6 specifies a preference for support
// for ranges in range of IEEE 754-2008 binary64 (double precision)
// this does not accommodate 64 bit integers without loss of accuracy.
// As 64 bit integers are now widely used in software, it is desirable
// to expand support to to the full 64 bit (signed and unsigned) range
// this does not accommodate 64-bit integers without loss of accuracy.
// As 64-bit integers are now widely used in software, it is desirable
// to expand support to the full 64 bit (signed and unsigned) range
// i.e. -(2**63) -> (2**64)-1.
// -(2**63) ** Note: compilers see negative literals as negated positive numbers (hence the -1))
@ -822,7 +822,7 @@ TEST_CASE("parser class")
CHECK(accept_helper("9007199254740991"));
}
SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64 bit integers)
SECTION("over the edge cases") // issue #178 - Integer conversion to unsigned (incorrect handling of 64-bit integers)
{
// While RFC8259, Section 6 specifies a preference for support
// for ranges in range of IEEE 754-2008 binary64 (double precision)

View File

@ -172,7 +172,6 @@ TEST_CASE("constructors")
CHECK(j == j_reference);
}
SECTION("std::multimap<json::string_t, json>")
{
std::multimap<json::string_t, json> const o {{"a", json(1)}, {"b", json(1u)}, {"c", json(2.2)}, {"d", json(false)}, {"e", json("string")}, {"f", json()}};

View File

@ -229,7 +229,6 @@ using json_with_visitor_t = nlohmann::basic_json <
visitor_adaptor
>;
template <class Fnc>
void visitor_adaptor::visit(const Fnc& fnc) const
{

View File

@ -74,7 +74,7 @@ TEST_CASE("Better diagnostics")
SECTION("Parse error")
{
json _;
CHECK_THROWS_WITH_AS(_ = json::parse(""), "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error);
CHECK_THROWS_WITH_AS(_ = json::parse(""), "[json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON", json::parse_error);
}
SECTION("Wrong type in update()")

View File

@ -72,7 +72,6 @@ TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_j
CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
#ifdef JSON_HAS_CPP_17
CHECK_THROWS_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
CHECK_THROWS_WITH_AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", typename Json::out_of_range&);
@ -1522,9 +1521,9 @@ TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann
CHECK(j.value("foo", cpstr) == "bar");
CHECK(j.value("foo", castr) == "bar");
CHECK(j.value("foo", str) == "bar");
// this test is in fact different than the one below,
// this test is in fact different from the one below,
// because of 0 considering const char * overloads
// where as any other number does not
// whereas any other number does not
CHECK(j.value("baz", 0) == 42);
CHECK(j.value("baz", 47) == 42);
CHECK(j.value("baz", integer) == 42);

View File

@ -873,7 +873,6 @@ TEST_CASE("iterators 2")
}
}
#if JSON_HAS_RANGES
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
SECTION("ranges")

View File

@ -123,8 +123,7 @@ TEST_CASE("JSON pointers")
CHECK(j.contains(json::json_pointer("/a~1b")));
CHECK(j.contains(json::json_pointer("/m~0n")));
// unescaped access
// access to nonexisting values yield object creation
// unescaped access to nonexisting values yield object creation
CHECK(!j.contains(json::json_pointer("/a/b")));
CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42);
CHECK(j.contains(json::json_pointer("/a/b")));

Some files were not shown because too many files have changed in this diff Show More