mirror of
https://github.com/nlohmann/json.git
synced 2026-11-12 23:20:46 +00:00
deploy: cdfb130fa6
This commit is contained in:
1 parent
8ddeea7128
commit
5097c20962
516 files changed
+7306
-5984
No files matched your search
@@ -76,7 +76,7 @@ The order name/value pairs are added to the object are *not* preserved by the li
|
||||
|
||||
### Cross-`basic_json` conversion requirements
|
||||
|
||||
When converting an object from one `basic_json` specialization to another via the [converting constructor](https://json.nlohmann.me/api/basic_json/basic_json/index.md) (overload 4), the target `object_t`'s `key_type` must be directly constructible from the source `basic_json`'s `string_t` type (or more generally, from the source object's key type). If this requirement is not met, the conversion does not fail; instead, the object is silently converted as an array of key-value pairs, which is incorrect. See [issue #3425](https://github.com/nlohmann/json/issues/3425) for details and an example.
|
||||
When converting an object from one `basic_json` specialization to another via the [converting constructor](https://json.nlohmann.me/api/basic_json/basic_json/index.md) (overload 4), the target `object_t`'s `key_type` must be directly constructible from the source object's key type (with the default `std::map`, the source `basic_json`'s `string_t`). If this requirement is not met and the source string type is a range of characters, the object is converted as an array of key-value pairs, which is incorrect: the converting constructor's [`JSON_ASSERT`](https://json.nlohmann.me/api/macros/json_assert/index.md) fails; with its default definition, `assert`, the program aborts unless `NDEBUG` is defined, in which case the array is returned. If the source string type is not a range of characters, the conversion does not compile at all. See [`basic_json`](https://json.nlohmann.me/api/basic_json/basic_json/index.md) and [issue #3425](https://github.com/nlohmann/json/issues/3425) for details and an example.
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
Reference in new issue
Block a user