1 format1:

阿里P8架构师详解JSON.parseObject最全最权威使用姿势_json

// 转换成object
JSONObject jo = JSON.parseObject(result);
// 获取object中returnAddress字段;
jo.getString("returnAddress");

2 format2

阿里P8架构师详解JSON.parseObject最全最权威使用姿势_json_02

JSONArray detail = JSON.parseArray(result);
for (int i=0; i<detail.size();i++){
if(detail.get(i)!=null||!detail.get(i).equals("")){
JSONArray detailChild =detail.getJSONArray(i);
if(detailChild.getInteger(1)>Integer.valueOf(ship.get("shiptime").toString())){
ship.put("shiptime",detailChild.getInteger(1));
ship.put("desc",detailChild.getString(0));
}
}
}

3 JSON转Bean

JSONobject=>javaBean

JSONObject contentChild = contentsArray.getJSONObject(i);
QCCustomerScore.CustomerCore customerCore = JSON
.toJavaObject(contentChild, QCCustomerScore.CustomerCore.class);

String转javaBean

​​