JSON序列在C# [英] Json Serialization in 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屋!