title: cJSON c++ - add item object
body: <p>I'm using <a href="https://github.com/DaveGamble/cJSON" rel="nofollow noreferrer">cJSON Library</a>. For a body example request with JSON like this:</p>
  
  <pre><code>{
    "user": {
      "name":"user name",
      "city":"user city"  
    }  
  }
  </code></pre>
  
  <p>I add the objects like this and its work:</p>
  
  <pre><code>cJSON *root;
  cJSON *user;
  
  root = cJSON_CreateObject();
  cJSON_AddItemToObject(root,"user", user = cJson_CreateObject());
  cJSON_AddStringToObject(user, "name", name.c_str());
  cJSON_AddStringToObject(user, "city", city.c_str());
  </code></pre>
  
  <p>But now i have a body json little different:</p>
  
  <pre><code>{
    "user": {
      "informations:"{
          "name1":"user name1",
          "name2":"user name 2"
      }
    }  
  }
  </code></pre>
  
  <p>And try do add the object like this:</p>
  
  <pre><code>cJSON *root;
  cJSON *user;
  cJSON *info;
  
  root = cJSON_CreateObject();
  cJSON_AddItemToObject(root,"user", user = cJson_CreateObject());
  cJSON_AddItemToObject(user,"informations", info = cJson_CreateObject());
  cJSON_AddStringToObject(info, "name", name.c_str());
  cJSON_AddStringToObject(info, "city", city.c_str());
  </code></pre>
  
  <p>Its the right way to do this using cJSON? Because its not working and I don't know if the problem is in my C++ or in my Java client that sends the data to my C++ server.</p>