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

    try {
      jsonWriter.object();

      if (webACL.getWebACLId() != null) {
        jsonWriter.key("WebACLId").value(webACL.getWebACLId());
      }

      if (webACL.getName() != null) {
        jsonWriter.key("Name").value(webACL.getName());
      }

      if (webACL.getMetricName() != null) {
        jsonWriter.key("MetricName").value(webACL.getMetricName());
      }

      if (webACL.getDefaultAction() != null) {
        jsonWriter.key("DefaultAction");
        WafActionJsonMarshaller.getInstance().marshall(webACL.getDefaultAction(), jsonWriter);
      }

      java.util.List<ActivatedRule> rulesList = webACL.getRules();
      if (rulesList != null) {
        jsonWriter.key("Rules");
        jsonWriter.array();
        for (ActivatedRule rulesListValue : rulesList) {
          if (rulesListValue != null) {

            ActivatedRuleJsonMarshaller.getInstance().marshall(rulesListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public WebACL unmarshall(JsonUnmarshallerContext context) throws Exception {
    WebACL webACL = new WebACL();

    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("WebACLId", targetDepth)) {
          context.nextToken();
          webACL.setWebACLId(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("Name", targetDepth)) {
          context.nextToken();
          webACL.setName(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("MetricName", targetDepth)) {
          context.nextToken();
          webACL.setMetricName(StringJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("DefaultAction", targetDepth)) {
          context.nextToken();
          webACL.setDefaultAction(WafActionJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("Rules", targetDepth)) {
          context.nextToken();
          webACL.setRules(
              new ListUnmarshaller<ActivatedRule>(ActivatedRuleJsonUnmarshaller.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 webACL;
  }