1 # <small>nlohmann::basic_json::</small>emplace_back
4 template<class... Args>
5 reference emplace_back(Args&& ... args);
8 Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON
9 `#!json null` value, an empty array is created before appending the value created from `args`.
11 ## Template parameters
14 : compatible types to create a `basic_json` object
19 : arguments to forward to a constructor of `basic_json`
23 reference to the inserted element
27 Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
28 array or `#!json null`; example: `"cannot use emplace_back() with number"`
38 The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was
39 silently converted to a JSON array.
42 --8<-- "examples/emplace_back.cpp"
48 --8<-- "examples/emplace_back.output"
53 - Since version 2.0.8.
54 - Returns reference since 3.7.0.