You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
615 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create JSON values
  6. json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
  7. json j_number = 42;
  8. json j_object = {{"one", "eins"}, {"two", "zwei"}};
  9. // create copies using iterators
  10. json j_array_range(j_array.begin() + 1, j_array.end() - 2);
  11. json j_number_range(j_number.begin(), j_number.end());
  12. json j_object_range(j_object.begin(), j_object.find("two"));
  13. // serialize the values
  14. std::cout << j_array_range << '\n';
  15. std::cout << j_number_range << '\n';
  16. std::cout << j_object_range << '\n';
  17. }