private static JsonElement findInJson(JsonElement jsonElement, String jsonPath) {

        final String[] route = JSON_PATH_PATTERN.split(jsonPath);
        JsonElement result = jsonElement;

        for (String key : route) {
            key = key.trim();
            if (key.isEmpty())
                continue;

            if (result == null) {
                result = JsonNull.INSTANCE;
                break;
            }

            if (result.isJsonObject()) {
                result = ((JsonObject) result).get(key);
            } else if (result.isJsonArray()) {
                int value = Integer.valueOf(key) - 1;
                result = ((JsonArray) result).get(value);
            } else break;
        }

        return result;
    }
private static JsonElement findInJson ( JsonElement jsonElement , String jsonPath ) { final String [ ] route = JSON_PATH_PATTERN . split ( jsonPath ) ; JsonElement result = jsonElement ; for ( String key : route ) { key = key . trim ( ) ; if ( key . isEmpty ( ) ) continue ; if ( result == null ) { result = JsonNull . INSTANCE ; break ; } if ( result . isJsonObject ( ) ) { result = ( ( JsonObject ) result ) . get ( key ) ; } else if ( result . isJsonArray ( ) ) { int value = Integer . valueOf ( key ) - 1 ; result = ( ( JsonArray ) result ) . get ( value ) ; } else break ; } return result ; }
Finds an element in GSON's JSON document representation

@param jsonElement A (potentially complex) element to search in
@param jsonPath    Path in the given JSON to the desired table. Levels are dot-separated.
E.g. 'model._output.variable_importances'.
@return JsonElement, if found. Otherwise {@link JsonNull}.