Reading the Whole Array of Data from JSON
-
Hi I want the array of data under items, using this code i am able to get only the value under the first structure of data under items. How can i loop to the second structure of data under items, and further more if present. I am doing this using boost in c++. Can someone help on this. items=root.get_child("Serial"); for (boost::property_tree::ptree::iterator itprop = items.begin(); itprop != items.end(); ++itprop) { for(boost::property_tree::ptree::iterator it1=itprop->second.begin();it1!=itprop->second.end();++it1) { if(it1->first=="Items") { boost::property_tree::ptree& rootschild=it1->second; cout<<"Size is "<second.begin();it3!=it2->second. end();++it3) { std::cout<first<<": "<second.get_value()<<"\n"; } } } { "Header": { "Name": "abcd", "Email": "xyz" }, "Serial": [{ "flavour": "Green", "Color": "9", "code": "103", "Items": [{ "date": "2020/11", "value": "3.5", "serial": "01" }, { "date": "2020/10", "value": "3.4", "serial": "03" }] }] } With Regards
-
Hi I want the array of data under items, using this code i am able to get only the value under the first structure of data under items. How can i loop to the second structure of data under items, and further more if present. I am doing this using boost in c++. Can someone help on this. items=root.get_child("Serial"); for (boost::property_tree::ptree::iterator itprop = items.begin(); itprop != items.end(); ++itprop) { for(boost::property_tree::ptree::iterator it1=itprop->second.begin();it1!=itprop->second.end();++it1) { if(it1->first=="Items") { boost::property_tree::ptree& rootschild=it1->second; cout<<"Size is "<second.begin();it3!=it2->second. end();++it3) { std::cout<first<<": "<second.get_value()<<"\n"; } } } { "Header": { "Name": "abcd", "Email": "xyz" }, "Serial": [{ "flavour": "Green", "Color": "9", "code": "103", "Items": [{ "date": "2020/11", "value": "3.5", "serial": "01" }, { "date": "2020/10", "value": "3.4", "serial": "03" }] }] } With Regards
You've posted in the wrong forum. Try posting in this forum[^] instead.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.