📝 fix docs (#5217)

This commit is contained in:
Niels Lohmann
2026-06-29 22:15:18 +02:00
committed by GitHub
parent c37f82e563
commit c5b2b26fdc
93 changed files with 743 additions and 1209 deletions
+13 -4
View File
@@ -14,6 +14,8 @@ void update(const_iterator first, const_iterator last, bool merge_objects = fals
When `merge_objects` is `#!c false` (default), existing keys are overwritten. When `merge_objects` is `#!c true`,
recursively merges objects with common keys.
If the JSON value is `#!json null`, it is implicitly converted to an empty object before the values are inserted.
The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update)
function.
@@ -28,8 +30,8 @@ iterators (including the `end()` iterator) and all references to the elements ar
: JSON object to read values from
`merge_objects` (in)
: when `#!c true`, existing keys are not overwritten, but contents of objects are merged recursively (default:
`#!c false`)
: when `#!c true`, keys that exist in both objects and whose value in the source is itself an object are merged
recursively; all other values are overwritten as usual (default: `#!c false`)
`first` (in)
: the beginning of the range of elements to insert
@@ -37,6 +39,10 @@ iterators (including the `end()` iterator) and all references to the elements ar
`last` (in)
: the end of the range of elements to insert
## Exception safety
Basic guarantee: if an exception is thrown during the operation, the JSON value may be partially modified.
## Exceptions
1. The function can throw the following exceptions:
@@ -45,8 +51,6 @@ iterators (including the `end()` iterator) and all references to the elements ar
2. The function can throw the following exceptions:
- Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than
objects; example: `"cannot use update() with string"`
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
- Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last`
do not belong to the same JSON value; example: `"iterators do not fit"`
@@ -141,6 +145,11 @@ iterators (including the `end()` iterator) and all references to the elements ar
}
```
## See also
- [insert](insert.md) add values to an array/object
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
## Version history
- Added in version 3.0.0.