File: insert_or_assign.md

package info (click to toggle)
jsoncons 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,584 kB
  • sloc: cpp: 136,382; sh: 33; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 931 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
### jsoncons::basic_json::insert_or_assign

```cpp
template <typename T>
pair<object_iterator, bool> insert_or_assign(const string_view_type& key, T&& value); (1)

template <typename T>
object_iterator insert_or_assign(const_object_iterator hint, const string_view_type& key, 
                                 T&& value); (2)
```

#### Parameters

    key
The member name used to look up and, if not found, to insert

    hint        
An object iterator that provides a hint where to insert the new json value

    value
Value to insert or assign

#### Return value

(1) returns a pair consisting of first, an iterator to the inserted value 
or the already existing value, 
and second, a bool indicating whether the insertion took place
(true for insertion, false for no insertion.)

(2) returns an iterator to the inserted value 
or the already existing value. 

#### Exceptions

Throws `std::domain_error` if not a json object.