title: Create JSON object dynamically
body: <p>I am trying to create JSON object with the following format.</p>
  
  <pre><code>{
  "tableID": 1,
  "price": 53,
  "payment": "cash",
  "quantity": 3,
  "products": [
      {
          "ID": 1,
          "quantity": 1
      },
      {
          "ID": 3,
          "quantity": 2
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <ol>
  <li><p>I know how to do this statically using JSONObject and JSONArray. But I need a more dynamic way cause the products array must be
  implemented so it has many objects not just 2.</p></li>
  <li><p>IS there a way to delete the contents of a JSONObject? eg I have the
  following JSONobject</p>
  
  <p>{
      "ID": 3,
      "quantity": 2
  }</p></li>
  </ol>
  
  <p>Could I somehow erase its values so i can reuse the object in an iteration?</p>