Fluent-json C# 的 JSON 生成器和解析器

程序名称:Fluent-json

授权协议: BSD

操作系统: Windows

开发语言: C#

Fluent-json 介绍

Fluent-json 是 C# 的 JSON 生成器和解析器,除了支持基本的 JSON 操作,还可以映射自定义类到 JSON
数据格式。这是一个线程安全的库,同时确保强类型安全。

示例代码

JsonEncoder<Book> encoder = Json.EncoderFor<Book>(config => config
    .MapType<Book>(map => map

        .AllFields()

        // DateTime can't be encoded to native json. Conversion is required.
        .Field<DateTime>(field => field.pubDate, pubDate => pubDate
            .EncodeAs<string>(value => value.ToShortDateString())
        )

        // BookType can't be encoded either, let's convert it too.
        .Field<BookType>(field => field.type, type => type
            .EncodeAs<int>(value => (int)value)
            // Lets assume we would want to encode this field to a
            // different json field.
            .To("book_type")
        )
    )

    .MapType<Author>(map => map
        .AllFields()
    )

    .UseTidy(true)
);

Book book = new Book();
book.title = "Around the world in 80 days";
book.tags = new List<string> { "traveling", "adventure" };
book.pageCount = 342;
book.pubDate = DateTime.Now;

book.author = new Author();
book.author.forname = "Jules";
book.author.surname = "Verne";

string json = encoder.Encode(book);

Fluent-json 官网

http://code.google.com/p/fluent-json/

相关编程语言

MuPlayer 是一款跨平台、轻量级的音频播放解决方案,...
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个...
DewPlayer音乐播放器,样式很简单,而且很实用.播放器...
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Fla...
Speakker 是一个基于 Web 浏览器的音乐播放器,只提...
Player Framework 是一个开源的支持 HTML5 的视频播...