I have the following JSON that a 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've tried deserializing this to a class, like so:
thejsonresult = JsonConvert.DeserializeObject<JsonResult>(WebRequest.Json);
but received the following error:
Error reading string. Unexpected token: StartObject. Line 7, position 2.
I'm pretty lost and can't find any documentation on this. Anyone got a clue?
"at the start/end of that JSON string make it invalid. Remove those, and you've got a valid JSON string."is just because it's a string in C#, it's not part of the original JSON