I’m using JSON.NET to deserialize some JSON returned from a web service. Unfortunately, i’m getting the following err:
Cannot deserialize JSON array into type
‘System.Collections.Generic.Dictionary`2[System.String,System.String]’.
but i have no idea how to debug it. is there a way to have it tell me what the offending JSON is? or even what it’s trying to deserialize it to? unfortunately this is part of a larger object hierarchy, so it’s not just a simple piece of JSON. i’ve tried stepping through the code, but there’s miles of it and little documentation. If it could at least tell me the offending piece, then i can see if maybe i cocked up my object definition or something.
Figured out where to look after walking through tons of code. line 1118ish JsonSerializerInternalReader is:
and if you put a breakpoint there and watch “property” you can see what property is getting serialized. since it does it in order of the json string you can watch that and see the last one to successfully get set. then you at least know where the serializer is failing.
it would be helpful, however, if JSON.net raised at least the property name in the error, but until that happens, this seems to be the next best thing.