Recommended Sites:
Http://www.runoob.com/json/json-stringify.html
Http://www.w3school.com.cn/json/json_eval.asp
Transferred from: http://www.jb51.net/article/120737.htm
First, the introduction of the Json-lib package
1. The JSON string is converted to a list object:
Jsonarray Jsonarray = Jsonarray.fromobject (jsonstring); list<config> list = (list) jsonarray.tocollection (Jsonarray,class.class);
2. JSON string converted to object
Jsonobject jsonobject = Jsonobject.fromobject (jsonstring); Object object = (object) Jsonobject.tobean (Jsonobject, Object.class);
3. The JSON string is converted to an object containing the list object
Jsonobject jsonobject = Jsonobject.fromobject (jsonstring); map<string, class> listmap = new hashmap<string, class> (); Listmap.put ("list", Listobject.class);
Object object = (object) Jsonobject.tobean (Jsonobject, Object.class, Listmap);
The Ps:object object may contain multiple objects, and the object may contain multiple list objects nested within each other.
Simply assemble all the list object values into a Map object, and the corresponding key will be the name of the list object's property.
JSON objects and Java object transformations