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";
}

你可能感兴趣的:(webservice)