Hi, I want to create a JSON array.
I tried using:
JSONArray jArray = new JSONArray(); while(itr.hasNext()){ int objId = itr.next(); jArray.put(objId, odao.getObjectName(objId)); } results = jArray.toString();
Note: odao.getObjectName(objId) retrieves the name based on the "object identifier" called objId.
However, I get a very funny look, like
[null,null,null,"SomeValue",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"AnotherValue",null,null,null,null,null,null,null,null,null,null,"SomethingElse","AnotherOne","LastOne"]
If only "LastOne" is displayed when I retrieve it using jQuery .
The array should look like
{["3": "SomeValue"], ["40": "AnotherValue"], ["23": "SomethingElse"], ["9": "AnotherOne"], ["1": "LaStone"] }
The numbers are not displayed for any reason in the array I get.