Java tutorial
//package com.java2s; import org.json.JSONException; import org.json.JSONObject; public class Main { private static final int ERROR_CODE_REQUEST_TOO_FREQUENTLY = 100070; public static boolean isRequestTooFrequently(Throwable throwable) { return getResponseErrorCode(throwable) == ERROR_CODE_REQUEST_TOO_FREQUENTLY; } private static int getResponseErrorCode(Throwable throwable) { try { String s = "{ \"success\": \"false\", \"destinations\":[ { \"id\": \"5025:125:1\", \"destinationSet\": \"5025:125:1\", \"HTTPCode\": \"401\", \"code\": \"100077\" }] }"; JSONObject object = new JSONObject(s); String code = object.getJSONArray("destinations").getJSONObject(0).optString("code"); return Integer.valueOf(code); } catch (JSONException e1) { System.out.println("error parse error response, message: "); return -1; } catch (NumberFormatException e2) { System.out.println("error parse error response, invalid error code(non integer)!"); return -1; } } }