Source:
public List<StreamsDatum> process(StreamsDatum entry) { List<StreamsDatum> result = Lists.newArrayList(); String json = null; ObjectNode document = null; LOGGER.debug("{} processing {}", STREAMS_ID); if( entry.getDocument() instanceof ObjectNode ) { document = (ObjectNode) entry.getDocument(); try { json = mapper.writeValueAsString(document); } catch (JsonProcessingException e) { e.printStackTrace(); } } else if( entry.getDocument() instanceof String ) { json = (String) entry.getDocument(); try { document = mapper.readValue(json, ObjectNode.class); } catch (IOException e) { e.printStackTrace(); return null; } } Preconditions.checkNotNull(document); if( StringUtils.isNotEmpty(json)) { Object srcResult = null; try { srcResult = jsonPath.read(json); } catch( Exception e ) { e.printStackTrace(); LOGGER.warn(e.getMessage()); } Preconditions.checkNotNull(srcResult); String[] path = StringUtils.split(pathExpression, '.'); ObjectNode node = document; for (int i = 1; i < path.length-1; i++) { node = (ObjectNode) document.get(path[i]); } Preconditions.checkNotNull(node); if( srcResult instanceof JSONArray ) { try { ArrayNode jsonNode = mapper.convertValue(srcResult, ArrayNode.class); if( jsonNode.size() == 1 ) { JsonNode item = jsonNode.get(0); node.set(destNodeName, item); } else { node.set(destNodeName, jsonNode); } } catch (Exception e) { e.printStackTrace(); LOGGER.warn(e.getMessage()); } } else if( srcResult instanceof JSONObject ) { try { ObjectNode jsonNode = mapper.convertValue(srcResult, ObjectNode.class); node.set(destNodeName, jsonNode); } catch (Exception e) { e.printStackTrace(); LOGGER.warn(e.getMessage()); } } else if( srcResult instanceof String ) { try { node.put(destNodeName, (String) srcResult); } catch (Exception e) { e.printStackTrace(); LOGGER.warn(e.getMessage()); } } } result.add(new StreamsDatum(document)); return result; }

Target:
public List<StreamsDatum> process(StreamsDatum entry) { List<StreamsDatum> result = Lists.newArrayList(); String json = null; ObjectNode document = null; LOGGER.debug("{} processing {}", STREAMS_ID); if( entry.getDocument() instanceof ObjectNode ) { document = (ObjectNode) entry.getDocument(); try { json = mapper.writeValueAsString(document); } catch (JsonProcessingException e) { e.printStackTrace(); } } else if( entry.getDocument() instanceof String ) { json = (String) entry.getDocument(); try { document = mapper.readValue(json, ObjectNode.class); } catch (IOException e) { e.printStackTrace(); return null; } } Preconditions.checkNotNull(document); if( StringUtils.isNotEmpty(json)) { Object srcResult = null; try { srcResult = jsonPath.read(json); } catch( Exception e ) { e.printStackTrace(); LOGGER.warn(e.getMessage()); } Preconditions.checkNotNull(srcResult); String[] path = StringUtils.split(pathExpression, '.'); ObjectNode node = document; for (int i = 1; i < path.length-1; i++) { node = (ObjectNode) document.get(path[i]); } Preconditions.checkNotNull(node); if( srcResult instanceof JSONArray ) { try { ArrayNode jsonNode = mapper.convertValue(srcResult, ArrayNode.class); if( jsonNode.size() == 1 ) { JsonNode item = jsonNode.get(0); node.set(destNodeName, item); } else { node.set(destNodeName, jsonNode); } } catch (Exception e) { LOGGER.warn(e.getMessage()); } } else if( srcResult instanceof JSONObject ) { try { ObjectNode jsonNode = mapper.convertValue(srcResult, ObjectNode.class); node.set(destNodeName, jsonNode); } catch (Exception e) { LOGGER.warn(e.getMessage()); } } else if( srcResult instanceof String ) { try { node.put(destNodeName, (String) srcResult); } catch (Exception e) { LOGGER.warn(e.getMessage()); } } } result.add(new StreamsDatum(document)); return result; }