PDA

View Full Version : [CLOSED] Help with JSON function



mapperez
May 29, 2014, 2:35 PM
I need to solve this function



protected void GetJSON() {


String StrDatos;
StrDatos = "{\r\n \"EventId\": 1001,\r\n \"CalendarId\": 4,\r\n \"Title\": \"CITA\",\r\n \"StartDate\": \"2014-05-29T10:00:00\",\r\n \"EndDate\": \"2014-05-29T10:15:00\",\r\n \"Location\": \"\",\r\n \"Notes\": \"MARIO PEREZ\",\r\n \"Url\": \"\",\r\n \"IsAllDay\": false,\r\n \"Reminder\": \"\",\r\n \"IsNew\": false,\r\n \"cls\": \"ext-cal-ev\",\r\n \"_positioned\": true,\r\n \"_left\": 0,\r\n \"_width\": 100,\r\n \"_top\": 420,\r\n \"_height\": 15,\r\n \"_weekIndex\": 4,\r\n \"spanLeft\": false,\r\n \"spanRight\": false,\r\n \"spanCls\": \"\"\r\n}";

try{
Dictionary<string, string>[] deserializedJSON = Ext.Net.JSON.Deserialize<Dictionary<string, string>[]>(StrDatos);
}catch(Exception errx){
X.Msg.Alert("TEST",errx.Message.ToString()).Show();
}



}

Daniil
May 29, 2014, 3:36 PM
Hi @mapperez,

I don't think that a JSON object can be deserialized to an array of Dictionaries.

But it can be deserialized into a Dictionary itself. So, if you change

Dictionary<string, string>[]
to

Dictionary<string, string>
it should work.