Question

I am trying to convert my .NET 4.0 class library to Windows Phone 8 class library to use it in my app. It turns out to be there is no JavaScriptSerializer available in Windows Phone 8 SDK. I am actually trying to deserialise my HttpClient response to my class object. How can I achieve that using windows phone 8 SDK.

Below is the code that I used in my .NET Class library

var serializer = new JavaScriptSerializer();
var dataObject = serializer.Deserialize<MyResponseClassObject>(result);
return dataObject;

Thanks,

Was it helpful?

Solution

You could use JSON.NET instead of JavaScriptSerializer: it has better performance and supports .NET 2, .NET 3.5, .NET 4, Silverlight and Windows Phone.

Here is the equivalent of your code with JSON.NET:

var dataObject = JsonConvert.DeserializeObject<MyResponseClassObject>(result);
return dataObject;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top