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

    try {
      jsonWriter.object();

      if (containerOverride.getName() != null) {
        jsonWriter.key("name").value(containerOverride.getName());
      }

      com.amazonaws.internal.SdkInternalList<String> commandList =
          (com.amazonaws.internal.SdkInternalList<String>) containerOverride.getCommand();
      if (!commandList.isEmpty() || !commandList.isAutoConstruct()) {
        jsonWriter.key("command");
        jsonWriter.array();
        for (String commandListValue : commandList) {
          if (commandListValue != null) {
            jsonWriter.value(commandListValue);
          }
        }
        jsonWriter.endArray();
      }

      com.amazonaws.internal.SdkInternalList<KeyValuePair> environmentList =
          (com.amazonaws.internal.SdkInternalList<KeyValuePair>) containerOverride.getEnvironment();
      if (!environmentList.isEmpty() || !environmentList.isAutoConstruct()) {
        jsonWriter.key("environment");
        jsonWriter.array();
        for (KeyValuePair environmentListValue : environmentList) {
          if (environmentListValue != null) {

            KeyValuePairJsonMarshaller.getInstance().marshall(environmentListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<ListTaskDefinitionFamiliesRequest> marshall(
      ListTaskDefinitionFamiliesRequest listTaskDefinitionFamiliesRequest) {
    if (listTaskDefinitionFamiliesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListTaskDefinitionFamiliesRequest> request =
        new DefaultRequest<ListTaskDefinitionFamiliesRequest>(
            listTaskDefinitionFamiliesRequest, "AmazonECS");
    String target = "AmazonEC2ContainerServiceV20141113.ListTaskDefinitionFamilies";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (listTaskDefinitionFamiliesRequest.getFamilyPrefix() != null) {
        jsonWriter.key("familyPrefix").value(listTaskDefinitionFamiliesRequest.getFamilyPrefix());
      }
      if (listTaskDefinitionFamiliesRequest.getNextToken() != null) {
        jsonWriter.key("nextToken").value(listTaskDefinitionFamiliesRequest.getNextToken());
      }
      if (listTaskDefinitionFamiliesRequest.getMaxResults() != null) {
        jsonWriter.key("maxResults").value(listTaskDefinitionFamiliesRequest.getMaxResults());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

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

    try {
      jsonWriter.object();

      if (taskDefinition.getTaskDefinitionArn() != null) {
        jsonWriter.key("taskDefinitionArn").value(taskDefinition.getTaskDefinitionArn());
      }

      com.amazonaws.internal.SdkInternalList<ContainerDefinition> containerDefinitionsList =
          (com.amazonaws.internal.SdkInternalList<ContainerDefinition>)
              taskDefinition.getContainerDefinitions();
      if (!containerDefinitionsList.isEmpty() || !containerDefinitionsList.isAutoConstruct()) {
        jsonWriter.key("containerDefinitions");
        jsonWriter.array();
        for (ContainerDefinition containerDefinitionsListValue : containerDefinitionsList) {
          if (containerDefinitionsListValue != null) {

            ContainerDefinitionJsonMarshaller.getInstance()
                .marshall(containerDefinitionsListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      if (taskDefinition.getFamily() != null) {
        jsonWriter.key("family").value(taskDefinition.getFamily());
      }

      if (taskDefinition.getRevision() != null) {
        jsonWriter.key("revision").value(taskDefinition.getRevision());
      }

      com.amazonaws.internal.SdkInternalList<Volume> volumesList =
          (com.amazonaws.internal.SdkInternalList<Volume>) taskDefinition.getVolumes();
      if (!volumesList.isEmpty() || !volumesList.isAutoConstruct()) {
        jsonWriter.key("volumes");
        jsonWriter.array();
        for (Volume volumesListValue : volumesList) {
          if (volumesListValue != null) {

            VolumeJsonMarshaller.getInstance().marshall(volumesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      if (taskDefinition.getStatus() != null) {
        jsonWriter.key("status").value(taskDefinition.getStatus());
      }

      com.amazonaws.internal.SdkInternalList<Attribute> requiresAttributesList =
          (com.amazonaws.internal.SdkInternalList<Attribute>)
              taskDefinition.getRequiresAttributes();
      if (!requiresAttributesList.isEmpty() || !requiresAttributesList.isAutoConstruct()) {
        jsonWriter.key("requiresAttributes");
        jsonWriter.array();
        for (Attribute requiresAttributesListValue : requiresAttributesList) {
          if (requiresAttributesListValue != null) {

            AttributeJsonMarshaller.getInstance().marshall(requiresAttributesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

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