code: public JSONObject toJson() throws IOException, JSONException {
      JSONObject json = new JSONObject();
  
      for (CapabilityInstance option : options.values()) {
        Object value = option.getValue();
  
        if (value == null) {
          continue;
        }
  
        if (value instanceof OperaProfile) {
          value = ((OperaProfile) value).toJson();
        } else if (value instanceof OperaArguments && ((OperaArguments) value).size() > 0) {
          value = ((OperaArguments) value).toJson();
        } else if (value instanceof Boolean) {
          value = (Boolean) value ? 1 : 0;
        } else {
          value = String.valueOf(value);
        }
  
        json.put(option.getIdentifier(), value);
      }
  
      return json;
    }
docs: Converts this instance to its JSON representation.
  
  @return the JSON representation of these settings
  @throws IOException   if an I/O error occurs
  @throws JSONException if an error occurs while encoding these settings as JSON