最近在做websservice接口对接问题,那边给的是json传递:我利用axis2解析出来的是result:
<ns2:getProductsResponse xmlns:ns2="http://www.chinawiserv.com/onecenter"><return>{"datas":[{"icon":"/images/product_icon/Service_pro_1.png","processId":2,"sequence":1,"description":"","productId":2,"name":"变更请求"}],"result":"0000","productSum":1,"info":"查询成功"}</return></ns2:getProductsResponse>
进行对result进行解析:
Iterator iterator = result.getChildElements();
OMElement result1 = null;
while (iterator.hasNext()) {
result1 = (OMElement) iterator.next();
System.out.println(result1.getText());
}
String re = result1.getText();
JSONObject json_test = JSON.parseObject(re);
System.out.println(json_test.getString("info"));
System.out.println(json_test.getString("result"));
可以输出info和result的值:查询成功和0000