public GetItemResult unmarshall(JsonUnmarshallerContext context) throws Exception { GetItemResult getItemResult = new GetItemResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; JsonToken token = context.currentToken; if (token == null) token = context.nextToken(); while (true) { if (token == null) return getItemResult; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("Item", targetDepth)) { getItemResult.setItem( new MapUnmarshaller<String, AttributeValue>( StringJsonUnmarshaller.getInstance(), AttributeValueJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("ConsumedCapacityUnits", targetDepth)) { context.nextToken(); getItemResult.setConsumedCapacityUnits( DoubleJsonUnmarshaller.getInstance().unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getCurrentDepth() <= originalDepth) { return getItemResult; } } token = context.nextToken(); } }
public GetItemResult unmarshall(JsonUnmarshallerContext context) throws Exception { GetItemResult getItemResult = new GetItemResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.currentToken; 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("Item", targetDepth)) { context.nextToken(); getItemResult.setItem( new MapUnmarshaller<String, AttributeValue>( StringJsonUnmarshaller.getInstance(), AttributeValueJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("ConsumedCapacity", targetDepth)) { context.nextToken(); getItemResult.setConsumedCapacity( ConsumedCapacityJsonUnmarshaller.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 getItemResult; }