code: public static String getString(JSONObject json, String key, String defaultValue) {
          if (json.containsKey(key)) {
              return json.getString(key);
          } else {
              return defaultValue;
          }
      }
docs: Returns the value of a JSON property as a String if it exists otherwise returns the defaultValue.
  @param json the JSONObject to check.
  @param key the key.
  @param defaultValue the value to return if the key is missing.
  @return the value for the key as a string.