/** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(RDSDataSpec rDSDataSpec, JSONWriter jsonWriter) {
    if (rDSDataSpec == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (rDSDataSpec.getDatabaseInformation() != null) {
        jsonWriter.key("DatabaseInformation");
        RDSDatabaseJsonMarshaller.getInstance()
            .marshall(rDSDataSpec.getDatabaseInformation(), jsonWriter);
      }

      if (rDSDataSpec.getSelectSqlQuery() != null) {
        jsonWriter.key("SelectSqlQuery").value(rDSDataSpec.getSelectSqlQuery());
      }

      if (rDSDataSpec.getDatabaseCredentials() != null) {
        jsonWriter.key("DatabaseCredentials");
        RDSDatabaseCredentialsJsonMarshaller.getInstance()
            .marshall(rDSDataSpec.getDatabaseCredentials(), jsonWriter);
      }

      if (rDSDataSpec.getS3StagingLocation() != null) {
        jsonWriter.key("S3StagingLocation").value(rDSDataSpec.getS3StagingLocation());
      }

      if (rDSDataSpec.getDataRearrangement() != null) {
        jsonWriter.key("DataRearrangement").value(rDSDataSpec.getDataRearrangement());
      }

      if (rDSDataSpec.getDataSchema() != null) {
        jsonWriter.key("DataSchema").value(rDSDataSpec.getDataSchema());
      }

      if (rDSDataSpec.getDataSchemaUri() != null) {
        jsonWriter.key("DataSchemaUri").value(rDSDataSpec.getDataSchemaUri());
      }

      if (rDSDataSpec.getResourceRole() != null) {
        jsonWriter.key("ResourceRole").value(rDSDataSpec.getResourceRole());
      }

      if (rDSDataSpec.getServiceRole() != null) {
        jsonWriter.key("ServiceRole").value(rDSDataSpec.getServiceRole());
      }

      if (rDSDataSpec.getSubnetId() != null) {
        jsonWriter.key("SubnetId").value(rDSDataSpec.getSubnetId());
      }

      com.amazonaws.internal.SdkInternalList<String> securityGroupIdsList =
          (com.amazonaws.internal.SdkInternalList<String>) rDSDataSpec.getSecurityGroupIds();
      if (!securityGroupIdsList.isEmpty() || !securityGroupIdsList.isAutoConstruct()) {
        jsonWriter.key("SecurityGroupIds");
        jsonWriter.array();
        for (String securityGroupIdsListValue : securityGroupIdsList) {
          if (securityGroupIdsListValue != null) {
            jsonWriter.value(securityGroupIdsListValue);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }