title: Garbage value in rapid json AddMember
body: <pre><code>{
      std::string result;
      RapidJSON::Value json;
      json.SetObject();
      for(int i = 0; i &lt; 5; ++i)
      {
          RapidJSON::Value data;
          data.SetObject();
          for(auto it = HashMap.begin(); it != HashMap.end(); it++)
          {
              RapidJSON::Value arrObj;
              arrObj.SetObject();
              for(auto it2 = it-&gt;second.begin(); it2 != it-&gt;second.end(); it2++)
              {
                  arrObj.AddMember(RapidJSON::StringRef(it2-&gt;first.c_str()), RapidJSON::StringRef(it2-&gt;second.c_str()), d.GetAllocator());
              }
              data.AddMember(RapidJSON::StringRef(it-&gt;first.c_str()), RapidJSON::Value(arrObj, d.GetAllocator()).Move(), d.GetAllocator());
  
          }
          json.AddMember(RapidJSON::StringRef(str.c_str()), RapidJSON::Value(data, d.GetAllocator()).Move(), d.GetAllocator());
      }
      
  cleanup:
      retJson.AddToJson(RapidJSON::StringRef(&quot;STATUS&quot;), json);
      result = retJson.ToString();
  }
  </code></pre>
  <p>I am using this method to convert a map to a json, but after each iteration of the outer for loop the value in the json value changes, the value assigned during the previous iteration becomes garbage values
  Can't find any solution,
  I have tried using creating a new Value and using the Move method, but that also didn't help</p>