From 72b910aee182e37865cadba9154e5a40396e2703 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 16 Oct 2014 11:35:11 -0400 Subject: [PATCH] Fixing null exception bug --- .../Api/Commands/ChartApi/GetTopArtistsCommand.cs | 5 ++--- src/IF.Lastfm.Core/Objects/LastAlbum.cs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IF.Lastfm.Core/Api/Commands/ChartApi/GetTopArtistsCommand.cs b/src/IF.Lastfm.Core/Api/Commands/ChartApi/GetTopArtistsCommand.cs index a239e11a..2575191f 100644 --- a/src/IF.Lastfm.Core/Api/Commands/ChartApi/GetTopArtistsCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/ChartApi/GetTopArtistsCommand.cs @@ -30,9 +30,8 @@ public async override Task> HandleResponse(HttpResponse if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode) { var jtoken = JsonConvert.DeserializeObject(json).SelectToken("artists"); - var artistsToken = jtoken.SelectToken("artists"); - var itemsToken = artistsToken.SelectToken("artist"); - var pageInfoToken = artistsToken.SelectToken("@attr"); + var itemsToken = jtoken.SelectToken("artist"); + var pageInfoToken = jtoken.SelectToken("@attr"); return PageResponse.CreateSuccessResponse(itemsToken, pageInfoToken, LastArtist.ParseJToken); } diff --git a/src/IF.Lastfm.Core/Objects/LastAlbum.cs b/src/IF.Lastfm.Core/Objects/LastAlbum.cs index e5c30595..78d51fe1 100644 --- a/src/IF.Lastfm.Core/Objects/LastAlbum.cs +++ b/src/IF.Lastfm.Core/Objects/LastAlbum.cs @@ -70,7 +70,8 @@ internal static LastAlbum ParseJToken(JToken token) if (tagsToken != null) { var tagToken = tagsToken.SelectToken("tag"); - a.TopTags = tagToken.Children().Select(LastTag.ParseJToken); + if (tagToken != null) + a.TopTags = tagToken.Children().Select(LastTag.ParseJToken); } a.ListenerCount = token.Value("listeners");