title: creating json string using JSONObject and JSONArray
body: <p>I have data like this:</p>
  
  <p>NewsItem :</p>
  
  <ul>
  <li>id</li>
  <li>title</li>
  <li>date</li>
  <li>txt</li>
  </ul>
  
  <p>There may be many NewsItems say 10. I have to send them to jquery.</p>
  
  <p>I am doing this:</p>
  
  <pre><code>JSONObject obj = new JSONObject();
  JSONArray arr = new JSONArray();
  
  for(int i = 0 ; i&lt; list.size() ; i++){
      p = list.get(i);
      arr.put(p.getId());
      arr.put(p.getTitle());
      arr.put(new MyDateFormatter().getStringFromDateDifference(p.getCreationDate()));
      arr.put(getTrimmedText(p.getText()));
      obj.put(""+i,arr);
      arr = new JSONArray();
  }
  </code></pre>
  
  <p>This will create a JSON string like this : <code>{"1":["id","title","date","txt"],"2":[......and so on...</code></p>
  
  <p>Is that correct way of doing this?</p>
  
  <p>How can I parse this string so that I can get each news item object in jQuery so that I can access attr.</p>
  
  <p>Like this:</p>
  
  <pre><code>obj.id,
  obj.title
  </code></pre>
  
  <p>Or if this is wrong way of creating JSON string, please suggest some better way with example of parsing in jQuery.</p>