json::Value arr = json::Array({1, 2, 3, 4, 5}); json::Value last = *(arr.end() - 1);
json::Value obj = json::Object({ {"name", "John"}, {"age", 30}, {"isStudent", true} }); for (auto it = obj.begin(); it != obj.end(); ++it) { std::string key = it.key(); json::Value value = it.value(); std::cout << key << ": " << value.asString() << std::endl; }In this example, we create a JSON object with three key-value pairs. We then use a for loop and the `begin` and `end` functions to iterate through the object. For each key-value pair, we get the key using the `key` function of the iterator, get the value using the `value` function, and print them out to the console. Package library: C++ JSON library (https://github.com/nlohmann/json)