How do I create a JSON Array?

后端 未结 3 1394
[愿得一人]
[愿得一人] 2021-01-13 06:31

Hi I want to create a JSON array.

I have tried using:

JSONArray jArray = new JSONArray();
  while(itr.hasNext()){
    int objId = itr.next();
jArray.         


        
3条回答
  •  天命终不由人
    2021-01-13 07:12

    The clue is in the documentation for JSONArray for method put(int index, String value)

    If the index is greater than the length of the JSONArray, then null elements will be added as necessary to pad it out.

提交回复
热议问题