Monday, 9 September 2013

Weird behavior with JsonConverter

Weird behavior with JsonConverter

So here's what's happening: I got this json string (after uploading an
image to imgur by using their API):
{
"data": {
"id": "123456",
"title": null,
"description": null,
"datetime": 1378731002,
"type": "image/png",
"animated": false,
"width": 1600,
"height": 900,
"size": 170505,
"views": 0,
"bandwidth": 0,
"favorite": false,
"nsfw": null,
"section": null,
"deletehash": "qZPqgs7J1jddVdo",
"link": "http://i.imgur.com/123456.png"
},
"success": true,
"status": 200
}
I'm trying to deserialize to a Dictionary using
JsonConvert.DeserializeObject like this:
richTextBox1.Text = json;
Dictionary<string, string> dic =
JsonConvert.DeserializeObject<Dictionary<string, string>>( json );
MessageBox.Show( dic["success"].ToString() );
Thing is, I can see the json string on the RichTextBox, but the MessageBox
after the JsonConvert never shows up... What am i missing here?
In fact, I can even put a breakpoint after the JsonCOnvert, it'll not be
triggered. What's happening?
Thank you.

No comments:

Post a Comment