Expected a JsonObjectContract or JsonDictionaryContract for type XY

Feb 23, 2010 at 7:28 PM

Hello, I am currently fixing an application.

 

GroovesharkResponse<T> responseObject = JsonConvert.DeserializeObject<GroovesharkResponse<T>>(responseData);

And I am getting that error: (which was not present before the data format that comes in changed)

 

 

Expected a JsonObjectContract or JsonDictionaryContract for type 'GroovesharkApiCompact.GroovesharkResultset', got 'Newtonsoft.Json.Serialization.JsonObjectContract'.

 

Here a snippet of the old data:

 

"{"header":{"session":"3e99a24240441f79d2e30158df200194","alerts":[{"AlertID":"2","Text":"woot","Type":"1","Target":"1","TSExpires":null},{"AlertID":"3","Text":"woot","Type":"1","Target":"1","TSExpires":null}]},"result":{"total":100,"resultSet":[{"name":"Amerika","ID":"24384810","artistName":"Rammstein"},{"name":"Du hast","ID":"24403883","artistName":"Rammstein"},{"name":"Bestrafe Mich","ID":"24401188","artistName":"Rammstein"},{"name":"Asche zu Asche","ID":"24351783","artistName":"Rammstein"},{"name":"Asche Zu Asche","ID":"24348602","artistName":"Rammstein"},{"name":"Bestrafe mich","ID":"24391240","artistName":"Rammstein"},{"name":"Du Hast","ID":"24416395","artistName":"Rammstein"},{"name":"","ID":"24406442","artistName":"Rammstein"},{"name":"Rammstein [Original]","ID":"24309012","artistName":"Rammstein"},{"name":"Rammstein \\/ Benzin","ID":"24324329","artistName":"Rammstein"},{"name":"Amour","ID":"24404642","artistName":"Rammstein"},{"name":"Feuer Frei","ID":"24379071","artistName":"Rammstein"}....

And here is the new data:

 

"{"header":{"session":"61af8f77f1be3532202c12bdf6322657","serviceVersion":"201001261","prefetchEnabled":true},"result":[{"SongID":"13489618","ArtistID":"198","Flags":"0","AlbumID":"1314936","TrackNum":"0","Score":26984.199539572,"Name":"Amerika","SongName":"Amerika","ArtistName":"Rammstein","AlbumName":"Don't Look Back","CoverArtFilename":"1314936.jpg","AvgRating":null,"Year":"2009","IsVerified":"0","SongVerified":"0","ArtistVerified":"1","AlbumVerified":"1","AvgDuration":null,"EstimateDuration":"226","IsLowBitrateAvailable":"1","QuerySongClicks":"76","QueryAlbumClicks":"0","QueryArtistClicks":"1","SongPlays":1337,"ArtistPlays":350329,"SongClicks":322,"AlbumClicks":0,"ArtistClicks":6,"Popularity":"0","SphinxWeight":101663,"DSName":"amerika","DALName":"dontlookback","DAName":"rammstein"},{"SongID":"8054766","ArtistID":"198","Flags":"0","AlbumID":"108715","TrackNum":"5","Score":26000.443149259,"Name":"Du hast","SongName":"Du hast","ArtistName":"Rammstein","AlbumName":"Sehnsucht","CoverArtFilename":"2e7250e25dbecaccab4506048419d5e8.png","AvgRating":null,"Year":"1998","IsVerified":"1","SongVerified":"1","ArtistVerified":"1","AlbumVerified":"1","AvgDuration":"236","EstimateDuration":"235","IsLowBitrateAvailable":"1","QuerySongClicks":"3","QueryAlbumClicks":"0","QueryArtistClicks":"1","SongPlays":2996,"ArtistPlays":350329,"SongClicks":66,"AlbumClicks":0,"ArtistClicks":6,"Popularity":"0","SphinxWeight":101663,"DSName":"duhast","DALName":"sehnsucht","DAName":"rammstein"},{"SongID":"12838125","ArtistID":"198","Flags":"0","AlbumID":"108715","TrackNum":"4","Score":25889.762165718,"Name":"Bestrafe Mich","SongName":"Bestrafe Mich","ArtistName":"Rammstein",...

 

What I need to fix that this eror dissapears?

 

 

 

Coordinator
Feb 23, 2010 at 8:40 PM

Could you check you are using the most recent version of Json.NET? I believe that error message comes from an older release.

Mar 16, 2010 at 9:20 PM

Ok, I have fixed the problem, I just had to changed the data format ;).

 

But now I have a new problem: following case

I have exported my data to json files. Now I make addition strings/ints into my structures that are used for the json import/export. How can I fix a "NullReferenceException" that would happen in that case? Are there any options I should use