1

Closed

Unexpected token: StartObject

description

When deserializing the following JSON:
 
\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
 
which is also:
 
{
"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 get the following error message:
"Error reading string. Unexpected token: StartObject. Line 7, position 2."
 
Happens with the latest release.
the code line for deserializing is:
 
thejsonresult = JsonConvert.DeserializeObject<JsonResult>(WebRequest.Json);
Closed May 27, 2012 at 8:39 AM by JamesNK
Your object doesn't match the JSON. Read the documentation.

comments

jbkkd wrote May 27, 2012 at 4:48 PM

Which documentation exactly?
This JSON has been taken from iTunes API, I highly doubt it's not JSON.
Moreover, I got this to deserialize in both LINQPad and DataContractJsonSerializer.

amendozacf wrote Jan 3 at 4:18 PM

I have this same issue. Were you able to solve this problem?