取出第三方接口中返回的json数据中data中的特定值

取出第三方接口中返回的json数据中data中的特定值
pox.xml中的jar包


        
            commons-beanutils
            commons-beanutils
            1.9.3
        
        
            commons-collections
            commons-collections
            3.2.1
        
        
            commons-lang
            commons-lang
            2.6
        
        
            commons-logging
            commons-logging
            1.1.1
        
        
            net.sf.ezmorph
            ezmorph
            1.0.6
        
        
            net.sf.json-lib
            json-lib
            2.2.3
            jdk15
        

第三方接口返回出来的数据:

{"code":0,"msg":"system.success","data":{"CustCode":"0","CustData":"C","ResposeCode":"0000","ResposeMsg":"成功","MeterNo":"6","ReadNum":"0.40","SwitchStatus":"关","RandomStr":"A","SignStr":"B"}}

现在想取出data中的ResposeMsg属性的值,也就是想拿到成功两个字
代码如下:

// singleMeterRead()方法是调用后返回上面的数据用Result接受一下
Result result = jingQiService.singleMeterRead(sNo, imIi);                  
Object objectdata = result.getData();
JSONObject json = JSONObject.fromObject(objectdata);
String resposeMsg = (String) json.get("ResposeMsg");
System.out.println(resposeMsg)

这样就拿到了

你可能感兴趣的:(JSON)