/** * Handles the given {@link JsonNode} and writes the responses to the given {@link OutputStream}. * * @param node the {@link JsonNode} * @param ops the {@link OutputStream} * @throws IOException on error */ protected void handleNode(JsonNode node, OutputStreamWrapper opsw) throws IOException { // handle objects if (node.isObject()) { handleObject(ObjectNode.class.cast(node), opsw); // handle arrays } else if (node.isArray()) { handleArray(ArrayNode.class.cast(node), opsw); // bail on bad data } else { throw new IllegalArgumentException("Invalid JsonNode type: " + node.getClass().getName()); } }