5

Mix10 演示期间,演示者 (Charlie Kindel) 说,在为 WP7 编写基于 Silverlight 的应用程序时,您将获得所有 Silverlight 3.0 和一些 Silverlight 4.0 混合。

那么为什么 System.Json 不见了?它包含在 Silverlight 3.0 中,并包含在 Silverlight 4.0 中。

Windows Phone 7 类库参考

4

7 回答 7

14

添加对的引用System.ServiceModel.Web以及对的引用System.Runtime.Serialization,它应该可以工作。 System.ServiceModel.Web似乎添加.JSONSerialization命名空间。

于 2011-08-02T19:53:49.543 回答
7

您也可以尝试使用 MIX RC 工具http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx中肯定存在的 DataContractJsonSerializer 。

于 2010-03-19T17:23:22.100 回答
4

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.

于 2010-04-16T13:36:36.040 回答
2

在我们的 Windows Phone 7 项目中,我们使用的是James Newton-Kings JSON.Net Library。只需下载代码并添加对Newtonsoft.Json.Silverlight的引用。奇迹般有效。

于 2010-09-01T06:11:14.840 回答
2

虽然 DataContractJsonSerializer 在 Silverlight 中可用,但它似乎在 Windows Phone 7 CTP 上不可用。也许它会在稍后出现,但它现在不存在。(我尝试在代码中使用它,System.Runtime.Serialization 程序集不包含此类,官方文档说 JSON 序列化是 Silverlight 中的东西,但 Windows Phone 7 中没有。)

但是,我能够使用JSON.NET库并从中创建一个 WP7 库项目。这让我在电话上获得了一个我正在成功使用的 JSON 基础设施。

于 2010-07-08T01:36:29.307 回答
1

我不能告诉你为什么 JSON 命名空间不在那里,但也许你可以使用支持 JSON 的 Windows Phone 7 的 OData 客户端库:

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

于 2010-03-19T17:21:15.257 回答
1

我也不知道为什么,但它在这个链接上说不支持命名空间

请参阅Silverlight for Windows Phone 中支持的功能

于 2010-03-22T07:31:07.120 回答