Skip to content

How to access the value from the json file using runtime key in c++ #2714

Answered by nlohmann
RanjithaHosur asked this question in Q&A
Discussion options

You must be logged in to vote
{
    "Version": 1.1,
    "Size": 1024,
    "integer": 600,
    "Map": [{"0": "india"}, {"1": "usa"}, {"2": "china"}, {"2": "japan"}],
    "name": "xxx",
}

Map maps to an array of objects, so you need to access it via

j["Map"][0]["1"]

(assuming the input was parsed to j)

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@RanjithaHosur
Comment options

@nlohmann
Comment options

@RanjithaHosur
Comment options

@nlohmann
Comment options

@nlohmann
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