public PutItemResult unmarshall(JsonUnmarshallerContext context) throws Exception {
    PutItemResult putItemResult = new PutItemResult();

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

    JsonToken token = context.currentToken;
    if (token == null) token = context.nextToken();

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

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("Attributes", targetDepth)) {
          putItemResult.setAttributes(
              new MapUnmarshaller<String, AttributeValue>(
                      StringJsonUnmarshaller.getInstance(),
                      AttributeValueJsonUnmarshaller.getInstance())
                  .unmarshall(context));
        }
        if (context.testExpression("ConsumedCapacityUnits", targetDepth)) {
          context.nextToken();
          putItemResult.setConsumedCapacityUnits(
              DoubleJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }
      token = context.nextToken();
    }

    return putItemResult;
  }
 // Test: put item with HashKey
 @Test
 public void putItemWithHashKey() {
   KeySchema schema =
       new KeySchema(
           new KeySchemaElement()
               .withAttributeName("id")
               .withAttributeType(ScalarAttributeType.S));
   createTable(tableName, schema);
   PutItemRequest request =
       new PutItemRequest().withTableName(tableName).withItem(createGenericItem());
   PutItemResult res = getClient().putItem(request);
   Assert.assertNotNull(res);
   Assert.assertNotNull(res.getConsumedCapacityUnits());
 }
 @Test
 public void putItemWithHashKeyAndRangeKeyOverwriteItem() {
   KeySchema schema =
       new KeySchema(
           new KeySchemaElement()
               .withAttributeName("id")
               .withAttributeType(ScalarAttributeType.S));
   schema.setRangeKeyElement(
       new KeySchemaElement().withAttributeName("range").withAttributeType(ScalarAttributeType.S));
   createTable(tableName, schema);
   PutItemRequest request =
       new PutItemRequest().withTableName(tableName).withItem(createGenericItem());
   getClient().putItem(request); // put item beforehand
   PutItemResult res = getClient().putItem(request); // Add another
   Assert.assertNotNull(res);
   Assert.assertNotNull(res.getConsumedCapacityUnits());
 }