I never figured out the difference between jsonArray and jsonObject before, but I finally figured it out today.
jsonArray is an array, containing data with [ ], and jsonObject is an object, containing data with { }.
Introducing an easy way to build a jsonArray in the frontend
var array=[]; for(int i=0;i<10;i++){ var item={}; item.a="a"+i; item.b="b"+i; array.push(item); } Ajax: params:{ data:JSON.stringify(array), type:1 }
Can receive in the background:
String data=request.getParameter("array"); JSONArray myArray=JSONArray.fromObject(data); for(int i=0;i<myArray.size();i++){ JSONObject object=myArray.getJSONObject(i); String a = object.getString('a'); String b = object.getString('b'); }
The above article about js creating jsonArray, transmitting it to the background and comprehensive analysis of the background is all the content shared by the editor. I hope it can give you a reference, and I also hope you will support Script Home.