Android JSON to String Convert getJsonErrorMsg(JSONObject errorResponse)

Here you can find the source of getJsonErrorMsg(JSONObject errorResponse)

Description

get Json Error Msg

Declaration

public static String getJsonErrorMsg(JSONObject errorResponse) 

Method Source Code

//package com.java2s;

import org.json.JSONException;
import org.json.JSONObject;

public class Main {
    public static String getJsonErrorMsg(JSONObject errorResponse) {
        String msg = "";

        try {//from w ww. j av  a2s.  co m
            JSONObject jsonObject = (JSONObject) errorResponse
                    .getJSONArray("errors").get(0);
            msg = jsonObject.getString("message");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return msg;
    }
}

Related

  1. pakJson(String json, String... jsons)
  2. getStringArray(JSONArray jsonArray)