push_back.cpp 440 B

12345678910111213141516171819202122232425
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create JSON values
  7. json array = {1, 2, 3, 4, 5};
  8. json null;
  9. // print values
  10. std::cout << array << '\n';
  11. std::cout << null << '\n';
  12. // add values
  13. array.push_back(6);
  14. array += 7;
  15. null += "first";
  16. null += "second";
  17. // print values
  18. std::cout << array << '\n';
  19. std::cout << null << '\n';
  20. }