This commit is contained in:
nlohmann
2026-07-09 04:52:37 +00:00
parent 279d757031
commit cb1c51b1d0
260 changed files with 552 additions and 510 deletions
+4
View File
@@ -74,6 +74,10 @@ Objects are stored as pointers in a `basic_json` type. That is, for any access t
The order name/value pairs are added to the object are *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to [RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON objects.
#### 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/#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.
## Examples
Example