JSON序列在C# [英] Json Serialization in C#

查看:112
本文介绍了JSON序列在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图序列化本地对象到JSON,但MSDN文档似乎总是迷惑我。我相信我想使用DataContractJsonSerializer但不能完全确定,因为我看到了不同的反应。我也曾经有人建议Newtonsoft。

I'm trying to serialize a local object to json but msdn documentation always seems to confuse me. I believe I am suppose to use the DataContractJsonSerializer but not completely sure, as I have seen mixed responses. I've also had someone recommend Newtonsoft.

有没有人有任何这方面的经验可以点我在正确的方向?

Does anyone have any experience with this that can point me in the right direction?

推荐答案

您可以使用的JavaScriptSerializer。

You could use the JavaScriptSerializer.

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx\">http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx

var thing = new Thing();
var json = new JavaScriptSerializer().Serialize(thing);

这篇关于JSON序列在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆