Hi I want to create a JSON array.
I have 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 a name based on the "object Id" which is called objId
However I get a very funny looking array 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"]
With only "LastOne" being displayed when I retrieve it using jQuery.
The Array SHould look like
{["3":"SomeValue"],["40":"AnotherValue"],["23":"SomethingElse"],["9":"AnotherOne"],["1":"LastOne"]}
The numbers aren't showing up at all for some reason in the array that I am getting