Results 1 to 1 of 1
- 08-26-2010, 11:46 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 1
- Rep Power
- 0
Question regarding JSONArray Usage/Behaviour
Hi All,
I am trying to write a dynamic JSON formatter based on my business logic. I am trying something like this:
Code:
JSONArray testArray= new JSONArray();
JSONObject obj1 = new JSONObject();
obj1.put("TestKey","Test Value");
testArray.add(obj1);
This works perfectly with the JSONObject showing up in the JSONArray.
However, when I try an anonymous class or simultanous JSONObject.put() inside JSONArray. The size of the array is updated but not the ENTRY i.e. I cant see any Key Value pair updated inside the array.
Code:
JSONArray testArray= new JSONArray();
JSONObject obj1 = new JSONObject();
testArray.add(obj1.put("TestKey","TestValue"));
[OR]
testArray.add(new JSONObject().put("TestKey","TestValue"));
Thank you all in advance.
Harsh
Similar Threads
-
JSONArray from JSON that doesn't contain any names?
By JoeShearn in forum New To JavaReplies: 4Last Post: 08-18-2010, 11:21 AM -
Put JSONObject to JSONArray?
By DigitalMan in forum Advanced JavaReplies: 3Last Post: 04-03-2010, 09:04 AM -
A question regarding apache Lucene usage
By need in forum LuceneReplies: 1Last Post: 03-16-2010, 10:58 AM -
BoxLayout Behaviour
By PetalumaBoy in forum AWT / SwingReplies: 4Last Post: 06-10-2009, 01:27 PM -
Strange behaviour in swing
By cbalu in forum AWT / SwingReplies: 1Last Post: 05-23-2008, 09:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks