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

来源:互联网 发布:c语言怎么输出五角星 编辑:程序博客网 时间:2024/06/05 17:57

 

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

原创粉丝点击