allocator_type
array
array_t
at
at
at
at
back
back
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
begin
begin
boolean_t
cbegin
cend
clear
const_pointer
const_reference
const_reverse_iterator
count
crbegin
crend
difference_type
dump
empty
end
end
erase
erase
erase
erase
find
find
front
front
get
get
get
get_allocator
get_ptr
get_ptr
get_ref
get_ref
insert
insert
insert
insert
insert
is_array
is_boolean
is_discarded
is_null
is_number
is_number_float
is_number_integer
is_object
is_primitive
is_string
is_structured
iterator_wrapper
iterator_wrapper
max_size
number_float_t
number_integer_t
object
object_t
operator value_t
operator ValueType
operator!=
operator!=
operator!=
operator+=
operator+=
operator+=
operator<
operator<
operator<<
operator<<
operator<=
operator=
operator==
operator==
operator==
operator>
operator>=
operator>>
operator>>
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
parse
parse
parse
parse_event_t
parser_callback_t
pointer
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
size
size_type
string_t
swap
swap
swap
swap
type
value
value
value_t
value_type
~basic_json

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>
template<class InputIT , typename std::enable_if< std::is_same< InputIT, typename basic_json_t::iterator >::value or std::is_same< InputIT, typename basic_json_t::const_iterator >::value , int >::type = 0>

nlohmann::basic_json::basic_json | ( | InputIT | first,
|  | InputIT | last
| ) |  |

inline

Constructs the JSON value with the contents of the range `[first, last)`. The semantics depends on the different types a JSON value can have:

- In case of primitive types (number, boolean, or string), first must be `begin()` and last must be `end()`. In this case, the value is copied. Otherwise, std::out_of_range is thrown.
- In case of structured types (array, object), the constructor behaves as similar versions for `std::vector`.
- In case of a null type, std::domain_error is thrown.

Template Parameters

  InputIT | an input iterator type (iterator or const_iterator)

Parameters

  [in] | first | begin of the range to copy from (included)
  [in] | last | end of the range to copy from (excluded)

Exceptions

  std::domain_error | if iterators are not compatible; that is, do not belong to the same JSON value; example: `"iterators are not compatible"`
  std::out_of_range | if iterators are for a primitive type (number, boolean, or string) where an out of range error can be detected easily; example: `"iterators out of range"`
  std::bad_alloc | if allocation for object, array, or string fails
  std::domain_error | if called with a null value; example: `"cannot use construct with iterators from null"`

Complexity
  Linear in distance between first and last.

Example
  The example below shows several ways to create JSON values by specifying a subrange with iterators.
  #include <json.hpp>
  using namespace nlohmann;
  int main()
  {
  // create JSON values
  json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
  json j_number = 42;
  json j_object = {{"one", "eins"}, {"two", "zwei"}};
  // create copies using iterators
  json j_array_range(j_array.begin() + 1, j_array.end() - 2);
  json j_number_range(j_number.begin(), j_number.end());
  json j_object_range(j_object.begin(), j_object.find("two"));
  // serialize the values
  std::cout << j_array_range << '\n';
  std::cout << j_number_range << '\n';
  std::cout << j_object_range << '\n';
  }
  nlohmann::basic_json
  a class to store JSON values
  Definition: json.hpp:191
  nlohmann::basic_json::end
  iterator end()
  returns an iterator to one past the last element
  Definition: json.hpp:3833
  nlohmann::basic_json::begin
  iterator begin()
  returns an iterator to the first element
  Definition: json.hpp:3774
  nlohmann::basic_json::find
  iterator find(typename object_t::key_type key)
  find an element in a JSON object
  Definition: json.hpp:3691
  nlohmann
  namespace for Niels Lohmann
  Definition: json.hpp:88
  Output (play with this example online):

      ["bravo","charly"]
      42
      {"one":"eins"}

  The example code above can be translated with

      g++ -std=c++11 -Isrc doc/examples/basic_json__InputIt_InputIt.cpp -o basic_json__InputIt_InputIt

Since
  version 1.0.0

Definition at line 1589 of file json.hpp.