reading arrays of json objects with nlohmann c++ library reading arrays of json objects with nlohmann c++ library json json

reading arrays of json objects with nlohmann c++ library


You can try this:

std::string ss= R"({    "test-data":    [        {            "name": "tom",            "age": 11        },        {            "name": "jane",            "age": 12        }    ]})";json myjson = json::parse(ss);auto &students = myjson["test-data"];for(auto &student : students) {    cout << "name=" << student["name"].get<std::string>() << endl;}