protected static boolean getBoolean(String key, JSONObject json) throws JSONException { String str = json.getString(key); if (null == str || "".equals(str) || "null".equals(str)) { return false; } return Boolean.valueOf(str); }
protected static int getInt(String key, JSONObject json) throws JSONException { String str = json.getString(key); if (null == str || "".equals(str) || "null".equals(str)) { return -1; } return Integer.parseInt(str); }
protected static long getLong(String key, JSONObject json) throws JSONException { String str = json.getString(key); if (null == str || "".equals(str) || "null".equals(str)) { return -1; } return Long.parseLong(str); }
protected static String getString(String name, JSONObject json, boolean decode) { String returnValue = null; try { returnValue = json.getString(name); if (decode) { try { returnValue = URLDecoder.decode(returnValue, "UTF-8"); } catch (UnsupportedEncodingException ignore) { } } } catch (JSONException ignore) { // refresh_url could be missing } return returnValue; }