[] webservice参数用json的字符串格式传递

    最近一项目,要提供webservice接口,本人用json字符串做完接口方法参数格式,不知道是否可行,高人指点一下,小弟在此谢过,然后用net.sf.json.jsonobject解析参数,要求参数格式为{'name':'get','int':1,'double',1.1,'null':null}。具体代码如下:
public string processservice(string data){
map map = null;
try {
jsonobject jsonobject = jsonobject.fromobject(data);

map = new hashmap();
for (iterator iter = jsonobject.keys(); iter.hasnext();) {
string key = (string) iter.next();
map.put(key, jsonobject.get(key));
}
} catch (exception e) {
return "传人的数据格式有误";
}
//处理传入数据
return "success";

猜你喜欢

转载自qqjavagood.iteye.com/blog/1151331