Oyatel/CometD.NET — Issue #14: Deserializing the IMessage
Author: MrGibbage
Created: 2012-01-25 13:01:38+00:00
State: open

I am using System.Web.Script.Serialization.JavaScriptSerialize to serialize and deserialize my messages. I am having trouble deserializing the messages. Here is a sample message:

{
"id":"3072",
"data":
{
"Application":
"{
\"Name\":\"growlnotify\",
\"Icon\":
{
\"Url\":null,
\"Data\":null,
\"IsSet\":false,
\"IsRawData\":false,
\"IsUrl\":false
},
\"MachineName\":\"ANARKI\",
\"SoftwareName\":\"GrowlConnector\",
\"SoftwareVersion\":\"1.0.0.0\",
\"PlatformName\":
\"Microsoft Windows NT 6.1.7601 Service Pack 1\",
\"PlatformVersion\":\"6.1.7601.65536\",
\"CustomTextAttributes\":{},
\"CustomBinaryAttributes\":{}
}",
"Encrypted":"true",
"RequestInfo":"
{
\"ReceivedFrom\":\"127.0.0.1\",
\"ReceivedBy\":\"ANARKI (86c9ad7e-6894-471f-b8cd-141601c3afa9)\",
\"ReceivedWith\":\"Growl/Win\",
\"TimeReceived\":\"\\/Date(1327489554253)\\/\",
\"RequestID\":\"4ec3df33-ec08-4759-9ec3-da3e1c4824d8\",
\"PreviousReceivedHeaders\":[],
\"HandlingInfo\":
[
\"Notification Origin: 127.0.0.1 [LOCAL MACHINE]\",
\"Forwarding to http://pelorus.org:8080/cometd (skip@pelorus.org)\"
]
}",
"NotificationTypes":"
[
{
\"Name\":\"General Notification\",
\"DisplayName\":\"General Notification\",
\"Icon\":
{
\"Url\":null,
\"Data\":null,
\"IsSet\":false,
\"IsRawData\":false,
\"IsUrl\":false
},
\"Enabled\":true,
\"MachineName\":\"ANARKI\",
\"SoftwareName\":\"Growl/Win\",
\"SoftwareVersion\":\"2.0.8.1\",
\"PlatformName\":\"Microsoft Windows NT 6.1.7601 Service Pack 1\",
\"PlatformVersion\":\"6.1.7601.65536\",
\"CustomTextAttributes\":{},
\"CustomBinaryAttributes\":{}
}
]",
"MessageType":"Registration"
},
"channel":"/chat/skip@pelorus.org"
}

What methods are people here using to deserialize their JSON objects? Anyone have any sample code I could look at?