"Unexpected Token: StartObject" when deserializing with Json.net

I have the following JSON that C # WebClient returned:

"\n\n\n{\n \"resultCount\":1,\n \"results\": [\n{\"wrapperType\":\"artist\", \"artistType\":\"Artist\", \"artistName\":\"Jack Johnson\", \"artistLinkUrl\":\"http://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4\", \"artistId\":909253, \"amgArtistId\":468749, \"primaryGenreName\":\"Rock\", \"primaryGenreId\":21}]\n}\n\n\n"

or, more clearly:

{
   "resultCount ":1,
   "results ":[
      {
         "wrapperType ":"artist ",
         "artistType ":"Artist ",
         "artistName ":"Jack Johnson ",
         "artistLinkUrl ":"http://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4 ",
         "artistId ":909253,
         "amgArtistId ":468749,
         "primaryGenreName ":"Rock ",
         "primaryGenreId ":21
      }
   ]
}

I tried to deserialize this into a class, like so:

 thejsonresult = JsonConvert.DeserializeObject<JsonResult>(WebRequest.Json);

but got the following error:

Error reading line. Unexpected token: StartObject. Line 7, position 2.

I am pretty lost and cannot find any documentation on this. Anyone got it?

+3
source share
3 answers

This makes no exceptions for me in LINQPad:

JsonConvert.DeserializeObject<JsonResult>("\n\n\n{\n \"resultCount\":1,\n \"results\": [\n{\"wrapperType\":\"artist\", \"artistType\":\"Artist\", \"artistName\":\"Jack Johnson\", \"artistLinkUrl\":\"http://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4\", \"artistId\":909253, \"amgArtistId\":468749, \"primaryGenreName\":\"Rock\", \"primaryGenreId\":21}]\n}\n\n\n")

If you get different results, you can try a different version of JSON.NET to see if it is an error.

+3
source

, , .

, , . , , , , Json .

+4

, " : StartObject", .

, , . , -, ZipCode, ZipCode.

, - , , .

+3

All Articles