JSON to entity Bean
data=[{"Xuhao": "201407140001", "Scaleno": "Down", "QRCode": "440100100002b993", "beforeweight": 15.85, "Fillingweight" : 30.50, "Steelno": "013267", "Fillingworkerid": "", "Fillingdate": "2014-07-14 09:29:01"},{"Xuhao": "201507140002", " Scaleno ":", "QRCode": "4401001000013475", "beforeweight": 15.85, "fillingweight": 30.50, "Steelno": "003212", " Fillingworkerid ":" "," Fillingdate ":" 2015-07-14 09:33:01 "}]
String strobject=request.getparameter ("data");
Fillingdetailrecordsentity requestbean= (fillingdetailrecordsentity) jsontoobject (StrObject, Fillingdetailrecordsentity.class);
public static <T> T jsontoobject (String jsonstring, class<t> pojocalss) {
try{
Object Pojo;
Net.sf.json.JSONObject jsonobject = Net.sf.json.JSONObject.fromObject (jsonstring);
Pojo = Net.sf.json.JSONObject.toBean (Jsonobject, POJOCALSS);
Return (T) Pojo;
}catch (Exception ex) {
Ex.printstacktrace ();
return null;
}
}
JSON to entity array list
Jsonarray Jsonarray = Jsonarray.fromobject (strobject);
list<fillingdetailrecordsentity> list = Jsonarray.tolist (Jsonarray, Fillingdetailrecordsentity.class);
JSON transform entity bean, array list