且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

c#将json对象反序列化/序列化为字典

更新时间:2022-01-12 22:26:14

您不想使用的现有第三方解决方案是一个良好的开端。 .NET还附带了您自己可以查看的JSON序列化程序。它不像其他人那样功能齐全,但如果你不想要第三方,它就有效。

The existing third party solutions you don't want to use is a good start. .NET also ships with its own JSON serializer you can look at. It isn't as full featured as others but it works if you don't want third party.

我个人强烈建议不要这样做。您已经依赖第三方代码。已经有许多JSON序列化器已经由知道JSON的人们多年努力开发。写自己的是浪费时间。可能
将无法处理您可能遇到的所有JSON案例,它可能不会那么快并且编写需要更长的时间。除非你有充分的理由,否则请使用第三方库。

Personally I would strongly recommend against this. You already depend upon 3rd party code. There are many JSON serializers already available that have been developed over years of effort by folks who know JSON. Writing your own is a waste of time. It probably won't handle all the cases you can come across with JSON, it likely won't be as fast and it'll take a lot longer to write. Unless you have a really good reason, use a third party library.