code: private int readOptionalInt(JSONValue val) {
  
          JSONString str = null == val ? null : val.isString();
          if (str != null) {
              try {
                  return Integer.valueOf(str.stringValue()).intValue();
              } catch (@SuppressWarnings("unused") NumberFormatException e) {
                  // Do nothing, return default value
              }
          }
          return 0;
      }
docs: Read an optional int value form a JSON value.
  @param val the JSON value that should represent the int.
  @return the int from the JSON or 0 reading the int fails.