| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

C# 的 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);

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

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1367130623453.html
JSON JSON开发包