JSON parsing on Windows Phone 7

I'm trying to do some simple JSON manipulation on Windows Phone 7. JSON.NET looks great, but VS2010 complains when I try to add a link to it.

This allowed me to add the Silverlight DLL, but warned me that this could lead to strange application behavior, so I am skeptical that this will actually work.

It looks like a great way to serialize and deserialize data, but I need to really request it. Can I just use this method to serialize it to IQueryable and then use LINQ? Can I somehow convert JSON to XML and use LINQ?

Or do I need to do hacker and sad string manipulations?

Update . For some reason, I can't even get VS2010 for recognizing a DataContractJsonSerializer :

  // works DataContractSerializer ser1 = new DataContractSerializer(); // the type or namespace 'DataContractJsonSerializer' could not be found ... DataContractJsonSerializer ser = new DataContractJsonSerializer(); 

Update 2 . The following is also reported:

 using System.Runtime.Serialization.Json; 

Mistake:

The type or namespace name 'Json' does not exist in the namespace 'System.Runtime.Serialization' (do you have a missing assembly reference?)

Am I doing something wrong or is JSON not supported in wp7?

Update 3 . It looks like the DataContractJsonSerializer is in the System.Servicemodel.Web namespace.

Update 4 . I added a link to the Silverlight JSON.NET DLL, and now it works fine. Fingers crossed.

+6
json windows-phone-7
source share
2 answers

Yes, according to your update 3 (almost):
DataContractJsonSerializer is in the System.Servicemodel.Web.dll assembly, but in the System.Runtime.Serialization.Json .

He caught a lot of people.

Glad you seem to have got this job.

+5
source share

Also, if you use the DataContract attribute, it is in the System.Runtime.Serialization and in System.Runtime.Serialization.dll .

0
source share

All Articles