public static Object getElement(final JsonNode json, final String name) {
        if (json != null && name != null) {
            var node = json;
            for (var nodeName : name.split("\\.")) {
                if (node != null) {
                    if (nodeName.matches("\\d+")) {
                        node = node.get(Integer.parseInt(nodeName));
                    } else {
                        node = node.get(nodeName);
                    }
                }
            }
            if (node != null) {
                if (node.isNumber()) {
                    return node.numberValue();
                } else if (node.isBoolean()) {
                    return node.booleanValue();
                } else if (node.isTextual()) {
                    return node.textValue();
                } else if (node.isNull()) {
                    return null;
                } else {
                    return node;
                }
            }
        }
        return null;
    }
Return the field with name in JSON as a string, a boolean, a number or a node.

@param json json
@param name node name
@return the field
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java