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