This commit is contained in:
nlohmann committed 2026-10-12 07:35:31 +00:00
1 parent 79119509a9
commit 22fba27145
555 files changed
+17342 -1394

No files matched your search

+30 -2
View File
@@ -50,13 +50,41 @@ Amortized constant.
silently converted to a JSON array.
```cpp
--8<-- "examples/emplace_back.cpp"
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json array = {1, 2, 3, 4, 5};
json null;
// print values
std::cout << array << '\n';
std::cout << null << '\n';
// add values
array.emplace_back(6);
null.emplace_back("first");
null.emplace_back(3, "second");
// print values
std::cout << array << '\n';
std::cout << null << '\n';
}
```
Output:
```json
--8<-- "examples/emplace_back.output"
[1,2,3,4,5]
null
[1,2,3,4,5,6]
["first",["second","second","second"]]
```
## See also