Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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);
 }
Example #4
0
 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;
 }