views:

1091

answers:

6

During a Mix10 presentation, the presenter (Charlie Kindel) said that when writing Silverlight based apps for WP7 you get all of Silverlight 3.0 with some of Silverlight 4.0 mixed in.

Why then is System.Json missing? It was included in Silverlight 3.0, and is included in Silverlight 4.0.

Windows Phone 7 Class Library Reference

A: 

I can't tell you why the JSON namespace isn't in there but perhaps you could use the OData Client Library for Windows Phone 7 which supports JSON:

http://www.microsoft.com/downloads/details.aspx?FamilyID=b251b247-70ca-4887-bab6-dccdec192f8d&displaylang=en

Martin Beeby
+5  A: 

You could also try using the DataContractJsonSerializer, which is definitely present in the MIX RC tools http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx.

Aurojit Panda
While this class is present in Silverlight, it is not present on Windows Phone 7.
legalize
It does appear to be there now (as of the Beta tools I'm looking at).
samjudson
I can't find it, and I have the final version of the tools.
Rosarch
@rosarch Really? http://msdn.microsoft.com/library/ff637320(v=VS.95).aspx would indicate otherwise.
Aurojit Panda
@Aurojit actually, it turns out I was looking in the wrong namespace.
Rosarch
+1  A: 

I'm not sure why either , but it says on this link that the namespace is not supported http://is.gd/aRLKg

Perry Loh
I guess I missed that. Thanks for pointing out what I obviously missed.
Freyday
+1  A: 

Seems that JSON is supported in Windows Phone 7 in the System.Runtime.Serialization.Json namespace, hopefully this will be useful, even though this question is a month old! Information from the TechDays in London (via Twitter) was not there personally.


Just an update is that the namespace and class I quoted here was incorrect so here is the correct namespace and class:

System.Servicemodel.Web and the Class is DataContractJsonSerializer for JSON Serialisation and Deserialisation on Windows Phone 7 - sorry about the inaccurate reply I have corrected after a comment posted here.

RoguePlanetoid
This namespace is not present on Windows Phone 7, sorry. It is in Silverlight, however.
legalize
Actually it is supported in Windows Phone 7 I quoted the wrong namespace and class, as I was unsure what it was at the time, thanks for the comment as it reminded me.DataContractJsonSerializer in System.Servicemodel.Web is used for JSON serialisation and deserialisation not System.Runtime.Serialization.Json as that is the Silverlight namespace - I had assumed at the time they were the same as information on the namespace was not apparent when I answered.
RoguePlanetoid
+1  A: 

While the DataContractJsonSerializer is available in Silverlight, it doesn't appear to be available on the Windows Phone 7 CTP. Maybe it will show up later, but its not there now. (I have tried using it in code, the System.Runtime.Serialization assembly does not include this class and the official documentation says that JSON serialization is something that is in Silverlight, but not in Windows Phone 7.)

However, I was able to take the JSON.NET library and create a WP7 library project out of it. This got me a JSON infrastructure on the Phone that I'm using successfully.

legalize
I tried to add a reference to the .NET compact version of JSON.NET from my wp7 app project, but it failed. Are you saying that you rebuilt the source?
Rosarch
+1  A: 

In our Windows Phone 7 project, we are using James Newton-Kings JSON.Net Library. Just download the code and add a reference to Newtonsoft.Json.Silverlight. Works like a charm.

froeschli