public @ Nonnull Iterable < JsonArray > arrays ( ) { final JsonArray parent = this ; return ( ) -> { final Iterator < JsonElement > iterator = parent . iterator ( ) ; return new Iterator < JsonArray > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public JsonArray next ( ) { return iterator . next ( ) . asArray ( ) ; } @ Override public void remove ( ) { iterator . remove ( ) ; } } ; } ; }
Convenience method to prevent casting JsonElement to JsonArray when iterating in the common case that you have an array of JsonArrays .