JSON

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;

String formDataStr = JSONObject.toJSONString(dRequest); //将对象转换为json字符串

resString = resource.post(String.class, formData); //{"errorCode":"4001","errorMessage":"接收业务通知失败,请稍后再试!","timestamp":"20180824093923"}
JSONObject jsStr = JSON.parseObject(resString); //HashMap$Node<K,V> 将json字符串转为可取值
String errorCode = jsStr.getString("errorCode");
String errorMessage = jsStr.getString("errorMessage");

posted @ 2018-08-24 10:13  wuyueping  阅读(82)  评论(0编辑  收藏  举报