I have not understood the difference between Jsonarray and jsonobject, and I finally figured it out today.
The Jsonarray is an array of [] containing data, Jsonobject is an object, and the data is contained in {}.
Introduce an easy way to build a jsonarray in the foreground
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
}
In the background can receive:
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 JS to create Jsonarray transmission to the background and the background of a comprehensive analysis is a small set to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.