public DevicePoolCompatibilityResult unmarshall(JsonUnmarshallerContext context)
      throws Exception {
    DevicePoolCompatibilityResult devicePoolCompatibilityResult =
        new DevicePoolCompatibilityResult();

    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("device", targetDepth)) {
          context.nextToken();
          devicePoolCompatibilityResult.setDevice(
              DeviceJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("compatible", targetDepth)) {
          context.nextToken();
          devicePoolCompatibilityResult.setCompatible(
              context.getUnmarshaller(Boolean.class).unmarshall(context));
        }
        if (context.testExpression("incompatibilityMessages", targetDepth)) {
          context.nextToken();
          devicePoolCompatibilityResult.setIncompatibilityMessages(
              new ListUnmarshaller<IncompatibilityMessage>(
                      IncompatibilityMessageJsonUnmarshaller.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 devicePoolCompatibilityResult;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      DevicePoolCompatibilityResult devicePoolCompatibilityResult,
      StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (devicePoolCompatibilityResult.getDevice() != null) {
        jsonGenerator.writeFieldName("device");
        DeviceJsonMarshaller.getInstance()
            .marshall(devicePoolCompatibilityResult.getDevice(), jsonGenerator);
      }
      if (devicePoolCompatibilityResult.getCompatible() != null) {
        jsonGenerator
            .writeFieldName("compatible")
            .writeValue(devicePoolCompatibilityResult.getCompatible());
      }

      java.util.List<IncompatibilityMessage> incompatibilityMessagesList =
          devicePoolCompatibilityResult.getIncompatibilityMessages();
      if (incompatibilityMessagesList != null) {
        jsonGenerator.writeFieldName("incompatibilityMessages");
        jsonGenerator.writeStartArray();
        for (IncompatibilityMessage incompatibilityMessagesListValue :
            incompatibilityMessagesList) {
          if (incompatibilityMessagesListValue != null) {

            IncompatibilityMessageJsonMarshaller.getInstance()
                .marshall(incompatibilityMessagesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }