code: private String readOptionalString(JSONObject json, String key, String defaultValue) {
  
          try {
              String str = json.getString(key);
              if (str != null) {
                  return str;
              }
  
          } catch (JSONException e) {
              LOG.debug("Reading optional JSON string failed. Default to provided default value.", e);
          }
          return defaultValue;
      }
docs: Read an optional string value form a JSON Object.
  @param json the JSON object to read from.
  @param key the key for the string value in the provided JSON object.
  @param defaultValue the default value, to be returned if the string can not be read from the JSON object.
  @return the string or the default value if reading the string fails.