我如何使用的JSONObject类?如何使用、JSONObject

2023-09-06 23:08:02 作者:想个怎么这么难呢

我建立在Windows Phone 7。我注意到在文档中,我可以:

I am building on Windows Phone 7. I noticed in the documentation I can:

JsonObject user = (JsonObject)JsonObject.Load(responseStream);
bool isMember = user["IsMember"];
string name = user["Name"];
int age = user["Age"];

我怎么能导入的JSONObject类?

How can I import the JsonObject class?

推荐答案

添加使用System.Json; 到文件的顶部

修改 看来,Windows Phone 7的不支持 System.Json 命名空间,所以你不能做这种方式。粗略搜索后,看来你必须使用 DataContractJsonSerializer 类,如中的这个的MSDN视频/源$ C ​​$ C。

Edit It seems that Windows Phone 7 doesn't support the System.Json namespace so you cannot do it this way. After a cursory search, it seems you have to use the DataContractJsonSerializer class as shown in this MSDN video/source code.

您可能还需要考虑使用 Json.NET 这似乎是很多比更有效在 DataContractJsonSerializer

You may also want to consider using Json.NET which appears to be much more efficient than the DataContractJsonSerializer.