/**
* 解析服务器返回的Json 数据的工具类
* Created by leven on 2016/10/26.
*/
public class JsonParseUtils {
/**
* @param response 服务器返回的 json 字符串
* @return 请求的状态码
*/
public static String getErrorCode(String response) {
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(response);
String errorCode = jsonObject.getString("errorCode");
return errorCode;
} catch (JSONException e) {
e.printStackTrace();
return "-1";
}
}
/**
* 判断网络请求数据是否成功
* @param response 返回的json数据
* @return
*/
public static boolean isSuccess(String response) {
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(response);
boolean isSuccess = jsonObject.getBoolean("isSuccess");
return isSuccess;
} catch (JSONException e) {
e.printStackTrace();
return false;
}
}
}
解析服务器返回的Json 数据的工具类
最新推荐文章于 2021-06-13 19:42:31 发布