@Override public Leaf deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode tree = (JsonNode) jp.readValueAsTree(); Leaf leaf = new Leaf(); leaf.value = tree.get("value").intValue(); return leaf; }
@Override public JSONOptions deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonLocation l = jp.getTokenLocation(); // logger.debug("Reading tree."); TreeNode n = jp.readValueAsTree(); // logger.debug("Tree {}", n); if (n instanceof JsonNode) { return new JSONOptions((JsonNode) n, l); } else { throw new IllegalArgumentException( String.format("Received something other than a JsonNode %s", n)); } }
private Object parseFirstRow(JsonParser jp, ParseState state, Class clazz) throws JsonParseException, IOException, JsonProcessingException, JsonMappingException { skipToField(jp, VALUE_FIELD_NAME, state); JsonNode value = null; if (atObjectStart(jp)) { value = jp.readValueAsTree(); jp.nextToken(); if (isEndOfRow(jp)) { state.docFieldName = VALUE_FIELD_NAME; Object doc = objectMapper.readValue(value, clazz); endRow(jp, state); return doc; } } skipToField(jp, INCLUDED_DOC_FIELD_NAME, state); if (atObjectStart(jp)) { state.docFieldName = INCLUDED_DOC_FIELD_NAME; Object doc = jp.readValueAs(clazz); endRow(jp, state); return doc; } return null; }