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

码农软件 · 软件分类 · JSON/BSON开发包 · 2019-04-01 06:14:09

软件介绍

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);

本文地址:https://codercto.com/soft/d/2596.html

Numerical Recipes 3rd Edition

Numerical Recipes 3rd Edition

William H. Press、Saul A. Teukolsky、William T. Vetterling、Brian P. Flannery / Cambridge University Press / 2007-9-6 / GBP 64.99

Do you want easy access to the latest methods in scientific computing? This greatly expanded third edition of Numerical Recipes has it, with wider coverage than ever before, many new, expanded and upd......一起来看看 《Numerical Recipes 3rd Edition》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具