title: Parsing deep nested json using property tree or rapidjson through recursion
body: <pre><code> static bool equalJson(Value &amp;json1, Value &amp;json2, Value &amp;reference, bool a) {
      for (Value::ConstMemberIterator itr = reference.MemberBegin(); itr &lt;= reference.MemberEnd(); itr++) {
  
          if (itr-&gt;value.GetType() == kArrayType) {
              for (auto itr1 = itr-&gt;value.Begin(); itr1 != itr-&gt;value.End(); itr1++) {
                  // cout&lt;&lt;itr-&gt;name.GetString()&lt;&lt;endl;//Gets the keys or members that are arrays on the Top Level
                  switch (itr1-&gt;GetType()) {
                      case kObjectType:
  
                          for (auto itr = itr1-&gt;MemberBegin(); itr != itr1-&gt;MemberEnd(); itr++) {
                              // cout&lt;&lt;itr-&gt;name.GetString()&lt;&lt;endl;//Elements(keys) of the arrays
                              if (itr-&gt;value.GetType() == kArrayType) {
                                  //cout&lt;&lt;itr-&gt;name.GetString()&lt;&lt;endl;//The keys inside the Top level array that are having sub arrays
                                 Document doc;
  
                                  //doc.CopyFrom(itr-&gt;name, doc.GetAllocator());
                                  doc.CopyFrom(itr-&gt;value, doc.GetAllocator());
  
                                  StringBuffer s;
                                  Writer&lt;StringBuffer&gt; w(s);
                                  doc.Accept(w);
                                  cout &lt;&lt; s.GetString() &lt;&lt; endl;
  
                                  // test::equalJson(json1,json2,doc,a);
  
  
  
                              }
                          }
                  }
              }
  
         }
  </code></pre>
  
  <p>I have a format something like this..</p>
  
  <pre><code> "object_array1": [
   {"key": null },
   {"key": null },
   {"key": null }
  ]
  
  
  What i have in the itr-&gt;value is
  
  [
   {"key": null },
   {"key": null },
   {"key": null }
  ]
  
  
  I would like to have some thing like this.....in the Document doc;
  
  
   {    
   "object_array1": [
   {"key": null },
   {"key": null },
   {"key": null }
  ]
  
   }
  
  
  In order to acheive this i did try...
  
    rapidjson::Value t_object(rapidjson::kObjectType);
    t_object.CopyFrom(itr-&gt;value, doc.GetAllocator());
    rapidjson::Value dir_name_key(itr-&gt;name.GetString(), 
    doc.GetAllocator());
    doc.AddMember(dir_name_key, t_object, doc.GetAllocator());
  </code></pre>
  
  <p>but it's still an array</p>
  
  <p>Your help will be highly appreciated.
  My reference json file:</p>
  
  <pre><code>{
  "array": [
  null
  ],
  "boolean": null,
  "null": null,
  "object": {
  "a": null,
  "c": null,
  "e": null
   },
  "number": null,
  
  "deep_nested_array": [
      {"object_array1": [
   {"key": null },
   {"key": null },
   {"key": null }
   ]}
    ],
   "object_array": [
   {"key": null },
   {"key": null },
   {"key": null }
   ],
   "string": null
    }
  </code></pre>
  
  <p>Main aim is to use recursion to loop inside n number of nested arrays or objects( as the arrays in the json will be random) to get each key and utilize it. while recursing i need that valid format of data as I showed in the above description to be stored it in doc to pass in the function  </p>
  
  <pre><code> static bool equalJson(Value &amp;json1, Value &amp;json2, Value &amp;reference, bool a) {
  
    while recursion:
    equaljson(json1,json2,doc,a);
  </code></pre>
  
  <p>If you have better suggestion than this it will be a great help.Thank you</p>