gpt4 book ai didi

c# - JSON序列化之间的区别

转载 作者:行者123 更新时间:2023-11-30 18:07:17 24 4
gpt4 key购买 nike

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

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

最佳答案

DataContractJsonSerializer

The primary purpose of the DataContractJsonSerializer is to be used with WCF, since one serialization is a big focus of 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.

.

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

关于c# - JSON序列化之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4095027/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com