JSON for Modern C++  3.0
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
nlohmann::basic_json::basic_json ( const basic_json other)
inline

Creates a copy of a given JSON value.

Parameters
[in]otherthe JSON value to copy
Complexity
Linear in the size of other.
Requirements
This function satisfies the Container requirements:
  • The complexity is linear.
  • As postcondition, it holds: other == basic_json(other).
Exceptions
std::bad_allocif allocation for object, array, or string fails.
Example
The following code shows an example for the copy constructor.
Output (play with this example ):
 The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/basic_jsonbasic_json_t.cpp -o basic_jsonbasic_json_t