title: How to add data to json using java?
body: <p>I have html form with two input field, which I am adding to json file on button click!</p>
  
  <p>JSON File</p>
  
  <pre><code>{
    "data": 
      {
        "names": [
          {
            "no": 1,
            "name": "John"
          },
          {
            "no": 2,
            "name": "Paul"
          }
          ]
       }
  }
  </code></pre>
  
  <p>Java File</p>
  
  <pre><code>String vNo = "";
  String vNAme = "";
  
  
  JSONParser parser = new JSONParser();
  
  
  
  if(request.getParameter("save")!=null) 
  {
     vNo = request.getParameter("no_form");
     vName = request.getParameter("name_form");
  
  
     JSONObject element = new JSONObject();
     element.put("no", vNo);
     element.put("name", vName);
  
     JSONArray names = new JSONArray();
  
     names.add();
  
   }
  </code></pre>
  
  <p>I m using JSON simple, I m getting confused How can I add data from input field to JSON array "names"?</p>
  
  <p>JSON File after adding content must look like this</p>
  
  <pre><code>{
    "data": 
      {
        "names": [
          {
            "no": 1,
            "name": "John"
          },
          {
            "no": 2,
            "name": "Paul"
          },
          {
            "no": 3,
            "name": "Jake"
          }
          ]
       }
  }
  </code></pre>