Skip to content
Discussion options

You must be logged in to vote
const auto& config1Obj = j["myjson"]["node1"][0]["config"]["config1"];
// Loop through the array and find the matching key
for (const auto& partItem : config1Obj) {
    if (partItem.contains("key") && partItem["key"] == key_val) {
        std::cout << "Found matching partItem: " << partItem.dump << std::endl;
    }
}

Hi @nlohmann - i managed to get required output with above code, Thanks !!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vinsha2k
Comment options

Answer selected by nlohmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants