insert__ilist.cpp 367 B

1234567891011121314151617
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create a JSON array
  7. json v = {1, 2, 3, 4};
  8. // insert range from v2 before the end of array v
  9. auto new_pos = v.insert(v.end(), {7, 8, 9});
  10. // output new array and result of insert call
  11. std::cout << *new_pos << '\n';
  12. std::cout << v << '\n';
  13. }