简体   繁体   English

JSON序列化之间的区别

[英]Difference between JSON Serialization

使用以下两种JSON序列化方法的优缺点是什么:

  1. System.Web.Script.Serialization
  2. DataContractJsonSerializer

DataContractJsonSerializer DataContractJsonSerializer

The primary purpose of the DataContractJsonSerializer is to be used with WCF, since one serialization is a big focus of WCF. DataContractJsonSerializer的主要用途是与WCF一起使用,因为一个序列化是WCF的一个重点。 Also, it is also better equipped to handle complex classes which have only certain properties available for serialization. 此外,它还可以更好地处理复杂的类,这些类只有某些属性可用于序列化。 This class is more strongly typed, has more knowledge about the type(s) it's handling and better error handling for badly-formed JSON. 这个类的类型更强,对它处理的类型有更多的了解,对于格式错误的JSON有更好的错误处理。

.

JavaScriptSerializer JavaScriptSerializer

This class on the other hand is much better equipped for quick serialization, it's a more cowboy approach. 另一方面,这门课程更适合快速序列化,这是一种更牛仔的方法。 There's less error checking and less control over what properties which are serialized. 错误检查较少,对序列化的属性控制较少。

Reference 参考

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

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