title: Iterating through objects in JsonCpp
body: <p>I have a C++ application that uses <a href="http://jsoncpp.sourceforge.net/">jsoncpp</a> to decode a JSON string. I have created the following function but it only shows me the top level objects... </p>
  
  <p>How do I get it to dump the entire object list?</p>
  
  <p><strong>--Function--</strong></p>
  
  <pre><code>SaveJSON( json_data ); 
  
  bool CDriverConfigurator::PrintJSONTree( Json::Value &amp; root, unsigned short depth /* = 0 */) 
  {
      printf( " {type=[%d], size=%d} ", root.type(), root.size() ); 
  
      if( root.size() &gt; 0 ) {
          for( Json::ValueIterator itr = root.begin() ; itr != root.end() ; itr++ ) {
              PrintJSONTree( itr.key(), depth+1 ); 
          }
          return true;
      }
  
      // Print depth. 
      for( int tab = 0 ; tab &lt; depth; tab++) {
          printf( "-"); 
      }
  
      if( root.isString() ) {
          printf( " %s", root.asString().c_str() ); 
      } else if( root.isBool() ) {
          printf( " %d", root.asBool() ); 
      } else if( root.isInt() ) {
          printf( " %d", root.asInt() ); 
      } else if( root.isUInt() ) {
          printf( " %d", root.asUInt() ); 
      } else if( root.isDouble() ) {
          printf( " %f", root.asDouble() ); 
      }
      else 
      {
          printf( " unknown type=[%d]", root.type() ); 
      }
  
  
      printf( "\n" ); 
      return true;
  }
  </code></pre>
  
  <p><strong>--- Input ----</strong> </p>
  
  <pre><code>{
     "modules":[
        {
           "config":{
              "position":[
                 129,
                 235
              ]
           },
           "name":"Modbus Task",
           "value":{
              "DeviceID":"This is the name",
              "Function":"01_READ_COIL_STATUS",
              "Length":"99",
              "Scan":"111",
              "Type":"Serve"
           }
        },
        {
           "config":{
              "position":[
                 13,
                 17
              ]
           },
           "name":"Modbus Connection",
           "value":{
              "Baud":"9600",
              "timeout":"2.5"
           }
        },
        {
           "config":{
              "position":[
                 47,
                 145
              ]
           },
           "name":"Modbus Device",
           "value":{
              "DeviceID":"55"
           }
        },
        {
           "config":{
              "position":[
                 363,
                 512
              ]
           },
           "name":"Function Something",
           "value":{
  
           }
        },
        {
           "config":{
              "position":[
                 404,
                 701
              ]
           },
           "name":"Function Something",
           "value":{
  
           }
        }
     ],
     "properties":{
        "Blarrg":"",
        "description":"",
        "name":"Modbus"
     },
     "wires":[
        {
           "src":{
              "moduleId":1,
              "terminal":"modbus.connection.output"
           },
           "tgt":{
              "moduleId":2,
              "terminal":"modbus.connection.input"
           }
        },
        {
           "src":{
              "moduleId":2,
              "terminal":"modbus.device.output"
           },
           "tgt":{
              "moduleId":0,
              "terminal":"modbus.device.output"
           }
        },
        {
           "src":{
              "moduleId":3,
              "terminal":"dataOut"
           },
           "tgt":{
              "moduleId":4,
              "terminal":"dataIn"
           }
        },
        {
           "src":{
              "moduleId":3,
              "terminal":"dataIn"
           },
           "tgt":{
              "moduleId":0,
              "terminal":"data1"
           }
        }
     ]
  }
  </code></pre>
  
  <p><strong>--Output--</strong></p>
  
  <pre><code>{type=[7], size=3} {type=[4], size=0} - modules
  {type=[4], size=0} - properties
  {type=[4], size=0} - wires 
  </code></pre>