public Hit unmarshall(JsonUnmarshallerContext context) throws Exception { Hit hit = new Hit(); 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("id", targetDepth)) { context.nextToken(); hit.setId(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("fields", targetDepth)) { context.nextToken(); hit.setFields( new MapUnmarshaller<String, java.util.List<String>>( context.getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))) .unmarshall(context)); } if (context.testExpression("exprs", targetDepth)) { context.nextToken(); hit.setExprs( new MapUnmarshaller<String, String>( context.getUnmarshaller(String.class), context.getUnmarshaller(String.class)) .unmarshall(context)); } if (context.testExpression("highlights", targetDepth)) { context.nextToken(); hit.setHighlights( new MapUnmarshaller<String, String>( context.getUnmarshaller(String.class), context.getUnmarshaller(String.class)) .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 hit; }
public Hits unmarshall(JsonUnmarshallerContext context) throws Exception { Hits hits = new Hits(); 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("found", targetDepth)) { context.nextToken(); hits.setFound(context.getUnmarshaller(Long.class).unmarshall(context)); } if (context.testExpression("start", targetDepth)) { context.nextToken(); hits.setStart(context.getUnmarshaller(Long.class).unmarshall(context)); } if (context.testExpression("cursor", targetDepth)) { context.nextToken(); hits.setCursor(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("hit", targetDepth)) { context.nextToken(); hits.setHit( new ListUnmarshaller<Hit>(HitJsonUnmarshaller.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 hits; }
public SuggestionMatch unmarshall(JsonUnmarshallerContext context) throws Exception { SuggestionMatch suggestionMatch = new SuggestionMatch(); 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("suggestion", targetDepth)) { context.nextToken(); suggestionMatch.setSuggestion(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.testExpression("score", targetDepth)) { context.nextToken(); suggestionMatch.setScore(context.getUnmarshaller(Long.class).unmarshall(context)); } if (context.testExpression("id", targetDepth)) { context.nextToken(); suggestionMatch.setId(context.getUnmarshaller(String.class).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 suggestionMatch; }