Source:
private Object convertToEvent(Object eventObject) { if (eventObject == null) { throw new ExecutionPlanRuntimeException("Null object received from the InputTransport to JsonSourceMapper"); } if (!(eventObject instanceof String)) { throw new ExecutionPlanRuntimeException("Invalid JSON object received. Expected String, but found " + eventObject.getClass() .getCanonicalName()); } if (!isJsonValid(eventObject.toString())) { log.error("Invalid Json String :" + eventObject.toString()); return null; } Object jsonObj; ReadContext readContext = JsonPath.parse(eventObject.toString()); if (isCustomMappingEnabled) { jsonObj = readContext.read(enclosingElement); if (jsonObj == null) { log.error("Enclosing element " + enclosingElement + " cannot be found in the json string " + eventObject.toString() + "."); return null; } if (jsonObj instanceof JSONArray) { JSONArray jsonArray = (JSONArray) jsonObj; List<Event> eventList = new ArrayList<Event>(); for (Object eventObj : jsonArray) { try { Event event = processCustomEvent(JsonPath.parse(eventObj)); eventList.add(event); } catch (ExecutionPlanRuntimeException e) { log.error(e.getMessage()); } } Event[] eventArray = new Event[eventList.size()]; eventArray = eventList.toArray(eventArray); return eventArray; } else { try { Event event = processCustomEvent(JsonPath.parse(jsonObj)); return event; } catch (ExecutionPlanRuntimeException e) { log.error(e.getMessage()); return null; } } } else { jsonObj = readContext.read(DEFAULT_ENCLOSING_ELEMENT); if (jsonObj instanceof JSONArray) { return convertToEventArrayForDefaultMapping(eventObject); } else { try { Event event = convertToSingleEventForDefaultMapping(eventObject); if (event == null) { log.error("Event" + eventObject + " contains incompatible attribute types and values."); return null; } return event; } catch (IOException e) { log.error("Invalid JSON string :" + eventObject.toString() + ". Cannot be converted to an event."); return null; } catch (ExecutionPlanRuntimeException e) { log.error(e.getMessage()); return null; } } } }

Target:
private Object convertToEvent(Object eventObject) { if (!(eventObject instanceof String)) { log.error("Invalid JSON object received. Expected String, but found " + eventObject.getClass() .getCanonicalName()); return null; } if (!isJsonValid(eventObject.toString())) { log.error("Invalid Json String :" + eventObject.toString()); return null; } Object jsonObj; ReadContext readContext = JsonPath.parse(eventObject.toString()); if (isCustomMappingEnabled) { jsonObj = readContext.read(enclosingElement); if (jsonObj == null) { log.error("Enclosing element " + enclosingElement + " cannot be found in the json string " + eventObject.toString() + "."); return null; } if (jsonObj instanceof JSONArray) { JSONArray jsonArray = (JSONArray) jsonObj; List<Event> eventList = new ArrayList<Event>(); for (Object eventObj : jsonArray) { Event event = processCustomEvent(JsonPath.parse(eventObj)); if (event != null) { eventList.add(event); } } Event[] eventArray = eventList.toArray(new Event[0]); return eventArray; } else { try { Event event = processCustomEvent(JsonPath.parse(jsonObj)); return event; } catch (ExecutionPlanRuntimeException e) { log.error(e.getMessage()); return null; } } } else { jsonObj = readContext.read(DEFAULT_ENCLOSING_ELEMENT); if (jsonObj instanceof JSONArray) { return convertToEventArrayForDefaultMapping(eventObject); } else { try { return convertToSingleEventForDefaultMapping(eventObject); } catch (IOException e) { log.error("Json string " + eventObject + " cannot be parsed to json object."); return null; } } } }