json::iterator c++

#include <iostream>
#include <json/json.h>

int main() {
    std::string jsonStr = R"({"key1": "value1", "key2": "value2", "key3": "value3"})";

    Json::CharReaderBuilder builder;
    Json::CharReader *reader = builder.newCharReader();

    Json::Value root;
    std::istringstream jsonStream(jsonStr);
    Json::parseFromStream(builder, jsonStream, &root, nullptr);

    for (Json::Value::iterator it = root.begin(); it != root.end(); ++it) {
        std::string key = it.key().asString();
        std::string value = (*it).asString();
        std::cout << "Key: " << key << ", Value: " << value << std::endl;
    }

    delete reader;
    return 0;
}