public static JsonNode getFirstNode(final String text, final String path) {
        try {
            var node = mapper.readValue(text, JsonNode.class);
            if (path != null) {
                node = (JsonNode) getElement(node, path);
            }
            return node;
        } catch (final IOException e) {
            LOGGER.error("Cannot get first node", e);
        }
        return null;
    }
Return the first node of a JSON response.

@param text JSON text
@param path path to find the first node
@return the first node of the JSON response or null if exception is thrown
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java