c#将json对象反序列化/序列化为字典 [英] c# deserialize /serialize json object into /from dictionary

查看:184
本文介绍了c#将json对象反序列化/序列化为字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找构建我自己的类来将json对象反序列化/序列化到/从字典中使用.Net中的内置函数而不是使用第三方。我可以从哪个指南或样本开始?

Hi, I am looking to build my own class to deserialize /serialize json object into /from dictionary with built in functions in .Net instead of using 3rd party. Is there any guideline or sample I can start with?

推荐答案

您不想使用的现有第三方解决方案是一个良好的开端。 .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.


这篇关于c#将json对象反序列化/序列化为字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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