Writing a full JSON Serializer in 100 lines of C# code

本文介绍了一个仅用约100行C#代码实现的JSON序列化器,该序列化器能够处理各种.NET对象并将其转换为JSON格式。支持的数据类型包括基本类型、日期时间等。

 

In my previous article I talked about the hunt for a good JSON parser/serializer. For my current project I only needed a serializer to generate JSON from any .NET object, so for now it’s a bit overkill to use a full blown JSON library.

After looking at the specs for JSON, I figured it couldn’t be too hard to write a JSON serializer in C#. Not only was it not that hard, it was very short too: about 100 lines of code (well, 110 without the empty lines).

The serializer can handle any regular data type, including DateTime (for which there is no standard in JSON).

Here it is: (feel free to use it for anything you like

 

 

http://www.dotnetkicks.com/ajax/Writing_a_full_JSON_Serializer_in_100_lines_of_C_code

 

 

http://www.blog.activa.be/2007/08/12/WritingAFullJSONSerializerIn100LinesOfCCode.aspx

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值