简体   繁体   English

视觉工作室2010中的json支持

[英]json support in visual studio 2010

I'm trying to work on a new project parsing some JSON data for a Silverlight 4 project (specifically created as a "Silverlight Business Application - Visual C#" project) using C# in Visual Studio 2010, and I can't find how to include the references to have parsers and native object support for JSON data. 我正在尝试在Visual Studio 2010中使用C#解析Silverlight 4项目(特别是作为“Silverlight业务应用程序 - Visual C#”项目创建)的一些JSON数据的新项目,我找不到如何包含对JSON数据具有解析器和本机对象支持的引用。

As far as I know my development tools are up to date (checked MS update). 据我所知,我的开发工具是最新的(检查MS更新)。

I know that I can probably just write my own parser but that seems like re-inventing the wheel. 我知道我可能只是编写自己的解析器,但这似乎重新发明了轮子。 Below are some lines that work in VS 2008 in another project of ours (can't post the files due to their being part of a business app): 以下是在我们的另一个项目中在VS 2008中工作的一些行(由于它们是业务应用程序的一部分而无法发布文件):

using System.Json;

results = (JsonObject)JsonObject.Load(e.Result);

I hope my description is adequate. 我希望我的描述充足。

Thanks for looking, 谢谢你的期待,

jnsohnumr jnsohnumr

I use System.Web.Script.Serialization.JavaScriptSerializer 我使用System.Web.Script.Serialization.JavaScriptSerializer

However, since it does not work in Visual Studio 2010 without configuration, you'll have to figure out how to make it work yourself. 但是,由于它在没有配置的Visual Studio 2010中不起作用,因此您必须弄清楚如何使其自行运行。

I've been using Json.Net. 我一直在使用Json.Net。 ( http://james.newtonking.com/pages/json-net.aspx ) to serialize. http://james.newtonking.com/pages/json-net.aspx )序列化。

[Update: http://json.codeplex.com/ for latest version] [更新: http//json.codeplex.com/获取最新版本]

[Update Sept 27 2017: https://github.com/JamesNK/Newtonsoft.Json latest version no longer works in visual studio 2010] [更新于2017年9月27日: https//github.com/JamesNK/Newtonsoft.Json最新版本不再适用于Visual Studio 2010]

Here you can find a very well-written open-source solution for parsing JSON data: 在这里,您可以找到一个用于解析JSON数据的编写良好的开源解决方案:
http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html

It is not native, but I have used it recently and did the job... 它不是原生的,但我最近使用它并完成了工作......

Add a reference to System.Json. 添加对System.Json的引用。 Add a reference to System.Json. 添加对System.Json的引用。 I just did it and now my using statement is working fine. 我刚刚做了,现在我的使用声明工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM