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
