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

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

被折叠的 条评论
为什么被折叠?



