title: create json object using cJSON.h
body: <p>I am trying to create JSON object like below but I am not able to add the second item in it e.g:</p>
  
  <pre><code>"CarType": "mercedes",
  "carID": "merc123"
  </code></pre>
  
  <p>and also other items.</p>
  
  <p>I want to create JSON like this:</p>
  
  <pre><code>{
    cars: [
      {
        "CarType": "BMW",
        "carID": "bmw123"
      },
      {
        "CarType": "mercedes",
        "carID": "merc123"
      },
      {
        "CarType": "volvo",
        "carID": "vol123r"
      },
      {
        "CarType": "ford",
        "carID": "ford123"
      }
    ]
  };
  </code></pre>
  
  <p>I have tried so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include "cJSON.h"
  
  int main (void){
      char field_name[32], value[32], *out;
      cJSON *root,*car;
  
      root  = cJSON_CreateObject();
      car=  cJSON_CreateArray();
  
      cJSON_AddItemToObject(root, "CarType", cJSON_CreateString("BMW"));
      cJSON_AddItemToObject(root, "carID", cJSON_CreateString("bmw123"));
      cJSON_AddItemToArray(car, root);
  
      out = cJSON_Print(car);
      printf("%s\n",out);
  
      return 0;
  }
  </code></pre>
  
  <p>My Output is something like this (indentation is exactly as showed here):</p>
  
  <pre><code>[{
          "CarType":  "BMW",
          "carID":    "bmw123"
      }]
  </code></pre>