mirror of
https://github.com/nlohmann/json.git
synced 2026-10-13 17:57:14 +00:00
deploy: 40a62947d3
This commit is contained in:
1 parent
79119509a9
commit
22fba27145
555 files changed
+17342
-1394
No files matched your search
@@ -34,13 +34,33 @@ Linear.
|
||||
`b`. Finally, the copy of `a` (which is the null value after the swap) is destroyed.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__copyassignment.cpp"
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json a = 23;
|
||||
json b = 42;
|
||||
|
||||
// copy-assign a to b
|
||||
b = a;
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << a << '\n';
|
||||
std::cout << b << '\n';
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__copyassignment.output"
|
||||
23
|
||||
23
|
||||
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
Reference in new issue
Block a user