JsonFx v2.0 - 用于.Net应用的JSON序列化框架

jopen 11年前

JsonFx 是一个 .NET 的 JSON 序列化器,提供统一的接口用于读写 JSON、BSON、XML 和 JsonML 。

运行支持:

  • .NET Framework 2.0, 3.0, 3.5, and 4.0
  • Silverlight 3.0, 4.0
  • Windows Phone 7
  • Mono Framework 2.6

特性

  • Unified interface for reading / writing JSON, BSON, XML, JsonML
  • Implements true LINQ-to-JSON (not simply LINQ-to-Objects over JSON types)
  • Naturally deserializes to standard CLR types, not JSON/XML-specific types
  • Supports reading/writing POCO classes
  • Supports reading/writing using DataContract, XmlSerialization, JsonName, attributes
  • Supports reading/writing using convention-based property renaming
  • Supports reading/writing C# 4.0 dynamic types
  • Supports reading/writing C# 3.0 Anonymous objects
  • Supports reading/writing LINQ queries
  • Supports custom reading/writing extensions & name resolution strategies
  • Dependency-injection-friendly for extremely flexible custom configurations
  • Stream-based serialization for reading/writing right off the wire
  • Provider allows automatic selection of serializer from Content-Type and Accept-Types HTTP headers

基础例子:

动态类型的映射 (default for .NET 4.0):

var reader = new JsonReader(); var writer = new JsonWriter();    string input = @"{ ""foo"": true, ""array"": [ 42, false, ""Hello!"", null ] }";  dynamic output = reader.Read(input);  Console.WriteLine(output.array[0]); // 42  string json = writer.Write(output);  Console.WriteLine(json); // {"foo":true,"array":[42,false,"Hello!",null]}

项目主页:http://www.open-open.com/lib/view/home/1367130895921