private ArrayList<Track> parseTopTracks(String json) {
    ArrayList<Track> tracks = new ArrayList<>();
    try {
      JsonNode jsonNode = this.objectMapper.readTree(json);
      for (JsonNode trackNode : jsonNode.get("tracks")) {
        JsonNode albumNode = trackNode.get("album");
        String albumName = albumNode.get("name").asText();
        String artistName = trackNode.get("artists").get(0).get("name").asText();
        String trackName = trackNode.get("name").asText();

        tracks.add(new Track(trackName, new Album(albumName, new Artist(artistName))));
      }
    } catch (IOException e) {
      throw new RuntimeException("Failed to parse JSON", e);
    }
    return tracks;
  }
private ArrayList < Track > parseTopTracks ( String json ) { ArrayList < Track > tracks = new ArrayList < > ( ) ; try { JsonNode jsonNode = this . objectMapper . readTree ( json ) ; for ( JsonNode trackNode : jsonNode . get ( "tracks" ) ) { JsonNode albumNode = trackNode . get ( "album" ) ; String albumName = albumNode . get ( "name" ) . asText ( ) ; String artistName = trackNode . get ( "artists" ) . get ( 0 ) . get ( "name" ) . asText ( ) ; String trackName = trackNode . get ( "name" ) . asText ( ) ; tracks . add ( new Track ( trackName , new Album ( albumName , new Artist ( artistName ) ) ) ) ; } } catch ( IOException e ) { throw new RuntimeException ( "Failed to parse JSON" , e ) ; } return tracks ; }
Parses an artist top tracks response from the
<a href="https://developer.spotify.com/web-api/get-artists-top-tracks/">Spotify API</a>

@param json The json response
@return A list of top tracks