}
try {
if (root.isArray()) {
ArrayNode input = (ArrayNode)root;
JsonRpc20BatchRequest batchReq = new JsonRpc20BatchRequest(input);
for (int i = 0; i < batchReq.getRequests().size(); i++) {
JsonRpcResponse result = batchReq.getBatchResponse().getResponses().get(i);
if (result == null) {
result = invoke(batchReq.getRequests().get(i));
batchReq.getBatchResponse().getResponses().set(i, result);
}
}
ArrayNode responses = batchReq.getBatchResponse().toJSONArray();
JacksonHelper.MAPPER.writeValue(response.getWriter(), responses);
} else {
if (root.has("jsonrpc")) {
JsonRpc20Request jsonReq = new JsonRpc20Request((ObjectNode)root);
JsonRpcResponse jsonResult = invoke(jsonReq);