/** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      DirectoryVpcSettings directoryVpcSettings, StructuredJsonGenerator jsonGenerator) {

    if (directoryVpcSettings == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (directoryVpcSettings.getVpcId() != null) {
        jsonGenerator.writeFieldName("VpcId").writeValue(directoryVpcSettings.getVpcId());
      }

      com.amazonaws.internal.SdkInternalList<String> subnetIdsList =
          (com.amazonaws.internal.SdkInternalList<String>) directoryVpcSettings.getSubnetIds();
      if (!subnetIdsList.isEmpty() || !subnetIdsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("SubnetIds");
        jsonGenerator.writeStartArray();
        for (String subnetIdsListValue : subnetIdsList) {
          if (subnetIdsListValue != null) {
            jsonGenerator.writeValue(subnetIdsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public DirectoryVpcSettings unmarshall(JsonUnmarshallerContext context) throws Exception {
    DirectoryVpcSettings directoryVpcSettings = new DirectoryVpcSettings();

    int originalDepth = context.getCurrentDepth();
    String currentParentElement = context.getCurrentParentElement();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.getCurrentToken();
    if (token == null) token = context.nextToken();
    if (token == VALUE_NULL) return null;

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("VpcId", targetDepth)) {
          context.nextToken();
          directoryVpcSettings.setVpcId(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("SubnetIds", targetDepth)) {
          context.nextToken();
          directoryVpcSettings.setSubnetIds(
              new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getLastParsedParentElement() == null
            || context.getLastParsedParentElement().equals(currentParentElement)) {
          if (context.getCurrentDepth() <= originalDepth) break;
        }
      }
      token = context.nextToken();
    }

    return directoryVpcSettings;
  }