Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Article Writing
  4. Reading the Whole Array of Data from JSON

Reading the Whole Array of Data from JSON

Scheduled Pinned Locked Moved Article Writing
c++data-structuresjsonhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Litu Sahoo
    wrote on last edited by
    #1

    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

    Greg UtasG 1 Reply Last reply
    0
    • L Litu Sahoo

      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

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #2

      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.

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups