Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: How to iterate arrays in 2.0 and get the key

$
0
0
So for a document like you proposed (which has an array of objects):
{
    "gameInfo" : [
        {
            "id" : 1,
            "name" : "foo"
        }
    ]
}
You would iterate over the elements of the array, then iterate over the elements of the object.
json::value& doc = /* fetch your document */;
for (auto& game : doc.at(U("gameInfo")).as_array())
{
    for (auto& p : game.as_object())
    {
        /* use p->first and p->second */
    }
}
roschuma

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>