最近一项目,要提供webservice接口,本人用json字符串做完接口方法参数格式,不知道是否可行,高人指点一下,小弟在此谢过,然后用net.sf.json.JSONObject解析参数,要求参数格式为{'name':'get','int':1,'double',1.1,'null':null}。具体代码如下:
publicStringprocessService(Stringdata){
Mapmap=null;
try{
JSONObjectjsonObject=JSONObject.fromObject(data);
map=newHashMap();
for(Iteratoriter=jsonObject.keys();iter.hasNext();){
Stringkey=(String)iter.next();
map.put(key,jsonObject.get(key));
}
}catch(Exceptione){
return"传人的数据格式有误";
}
//处理传入数据
return"success";
}