A. Java端
See: http://json-lib.sourceforge.net/
库包: json-lib-2.1-jdk13.jar, ezmorph-1.0.4.jar
API:
//将VO对象转换为json String
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(Object obj);
String jsonStr = jsonObj.toString();
//将json String转换为VO对象
Object obj = net.sf.json.JSONObject.fromObject(String jsonStr);
YourVO vo = (YourVO)JSONObject.toBean(obj , YourVO.class);
B JavaScript端
库包: json.js
API:
//将java script对象转换为json String
var jsonStr = $.toJSON(obj);
//将json String转换为java scrip对象
var obj = $.parseJSON(jsonStr, true);
See: http://json-lib.sourceforge.net/
库包: json-lib-2.1-jdk13.jar, ezmorph-1.0.4.jar
API:
//将VO对象转换为json String
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(Object obj);
String jsonStr = jsonObj.toString();
//将json String转换为VO对象
Object obj = net.sf.json.JSONObject.fromObject(String jsonStr);
YourVO vo = (YourVO)JSONObject.toBean(obj , YourVO.class);
B JavaScript端
库包: json.js
API:
//将java script对象转换为json String
var jsonStr = $.toJSON(obj);
//将json String转换为java scrip对象
var obj = $.parseJSON(jsonStr, true);