protected List < Article > readArticlesFromJson ( String json ) { Gson gson = new Gson ( ) ; JsonParser parser = new JsonParser ( ) ; JsonObject array = parser . parse ( json ) . getAsJsonObject ( ) ; JsonElement items = array . get ( "items" ) ; JsonArray itemsArray = items . getAsJsonArray ( ) ; List < Article > articles = new LinkedList <> ( ) ; for ( JsonElement element : itemsArray ) { Article article = gson . fromJson ( element , Article . class ) ; articles . add ( article ) ; } return articles ; }
Get the articles objects from JSON .