1. Interface incoming format
[{"Content": "123", "url": "123"},{"content": "123", "url": "123"}]
2. Code
List<voteoption> parsejsonvote (String options) {
list<voteoption> List = new Arraylist<voteoption > ();
Jsonarray Arry = jsonarray.fromobject (options);
for (int i = 0; i < arry.size (); i++) {
Jsonobject obj = Arry.getjsonobject (i);
voteoption JB = (voteoption) jsonobject.tobean (obj, voteoption.class);
List.add (JB);
}
return list;
}
Where Voteoption is the custom entity class
3. Another mode of conversion
Jsonarray Userarray = new Jsonparser (). Parse (JSON string with array). Getasjsonobject (). Get ("array name"). Getasjsonarray ();
Jsonobject obj = new Jsonparser (). Parse (JSON string). Getasjsonobject ();
The two import jar packages are different, 2 jsonarray and so on the package is Com.google.gson, and 3 jsonarray, such as the package is Net.sf.json.