JSON: DataContractJsonSerializer and Silverlight 4

I’m receiving JSON data on a messaging bus into Silverlight 4. For some reason, the codebase had used regex to extract the data from the JSON payload – Regex Hero Tester is nice. So following the obvious path, I removed the regex code, and replaced with:

        public class PriceData
        {
            public string bidPrefix { get; set; }
            public string bidPrice { get; set; }
            public string askPrefix { get; set; }
            public string askPrice { get; set; }
        }


            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(PriceData));
            MemoryStream mem = new MemoryStream(raw);
            PriceData pd = (PriceData)ser.ReadObject(mem);

Advertisement

~ by mdavey on August 11, 2011.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 273 other followers