Json.NET 6.0 received 4 releases this year, the latest last week. Over these releases, several new features have been added, including several F# specific features, support for JSONPath querying, ability to integrate with Dependency Injection frameworks, ability to Merge JSON objects and more.

Serializers shipped with the .NET framework, the Data Contract JSON Serializer and theJavaScriptSerializer, leave room for improvement both on features and performance front. Json.NET fills this gap and is already a popular open-source alternative within the .NET community. It comes with several features such as LINQ-to-JSON, BSON support, support foranonymous types, support for popular ORMs (EF and NHiberate) and more, not present in the built-in counterparts. This, combined with better performance. (see the feature comparison and detailed benchmarks)

Some important features introduced this year that make Json.NET even better -

  • JSON Merge - allows you to merge a JSON object or an array into another.

    This is similar to the jQuery's extend method, but is also recursive and gives more options in handling arrays - when merging arrays (including those nested within objects), you can specify whether they should be concatenated together, unioned, merged by position, or completely replaced.

    Merge also works with LINQ-to-JSON. Have a look at the tests to understand this feature better and the various use cases it supports.

  • Integration with Dependency Injection - you can now deserialize interfaces or abstract types directly if you specify a mechanism to resolve such a type at runtime, such as using a dependency injection framework like Autofac or Ninject. All you have to do is inherit from the DefaultContractResolver, and use your own resolver in the serializer.
  • Several F# specific features - support for discriminated unions, F# collections, F# lists, sequences, sets and maps. For new immutable collections, if collection of T has a constructor that takes IEnumerable<T> then Json.NET will automatically work when deserializing to that collection.
  • Ability to handle metadata properties, without having to guarantee JSON object property order. Json.NET uses metadata for some features such as preserving types or references and requires the metadata to be ordered before other properties for these features to work fine. A setting called MetadataPropertyHandling.ReadAhead can be set to enable this, at a slight cost of increased memory usage and lesser speed.
  • Full support for JSONPath querying. Similar to XPath, this is useful for navigating JSON data and can be useful if you only need specific values without necessarily deserializing the entire JSON object.

Other interesting features are ability to deserialize nested DataTables as well as arrays within DataTables, support for single-line comments within JSON, support for Windows Phone 8.1 and more. Refer to posts from James Newton-King for more details.

Another interesting and performant third-party alternative for serialization in .NET isServiceStack.Text (now commercial open source).

Json.NET Updates: Merge, Dependency Injection, F# and JSONPath Support的更多相关文章

  1. Compile-time Dependency Injection With Go Cloud's Wire 编译时依赖注入 运行时依赖注入

    Compile-time Dependency Injection With Go Cloud's Wire - The Go Blog https://blog.golang.org/wire Co ...

  2. [转载][翻译] IoC 容器和 Dependency Injection 模式

    原文地址:Inversion of Control Containers and the Dependency Injection pattern 中文翻译版本是网上的PDF文档,发布在这里仅为方便查 ...

  3. Srping - bean的依赖注入(Dependency injection)

    目录 1 概述 2 两种基本的依赖注入方式 2.1 构造函数方式 2.2Setter方式 3 其他依赖注入功能 3.1 <ref/>标签引用不同范围的bean 3.2 内部bean 3.3 ...

  4. [Angular] Component's dependency injection

    An Angular service registered on the NgModule is globally visible on the entire application. Moreove ...

  5. Ninject学习(一) - Dependency Injection By Hand

    大体上是把官网上的翻译下而已. http://www.ninject.90iogjkdcrorg/wiki.html Dependency Injection By Hand So what's Ni ...

  6. MVC Controller Dependency Injection for Beginners【翻译】

    在codeproject看到一篇文章,群里的一个朋友要帮忙我翻译一下顺便贴出来,这篇文章适合新手,也算是对MEF的一个简单用法的介绍. Introduction In a simple stateme ...

  7. 控制反转Inversion of Control (IoC) 与 依赖注入Dependency Injection (DI)

    控制反转和依赖注入 控制反转和依赖注入是两个密不可分的方法用来分离你应用程序中的依赖性.控制反转Inversion of Control (IoC) 意味着一个对象不会新创建一个对象并依赖着它来完成工 ...

  8. Dependency Injection

    Inversion of Control - Dependency Injection - Dependency Lookup loose coupling/maintainability/ late ...

  9. Inversion of Control Containers and the Dependency Injection pattern(转)

    In the Java community there's been a rush of lightweight containers that help to assemble components ...

随机推荐

  1. Rspec: feature spec 功能测试 测试JavaScript.

    我们要把应用各组件放在一起做集成 测试,这样才能保证模型和控制器之间能够良好契合. 在 RSpec 中,这种测试称为功能测试(feature spec),有时也称为验收测试(acceptance te ...

  2. Python下尝试实现图片的高斯模糊化

    资源下载 #本文PDF版下载Python下尝试实现图片的高斯模糊化#本文代码下载高斯模糊代码下载 高斯模糊是什么? (先来看一下维基百科对它的定义) 高斯模糊是模糊图像的结果.它是一种广泛使用的图形软 ...

  3. linux中whereis、which、find、location的区别和用法

    摘自:https://www.cnblogs.com/kex1n/p/5233821.html 1. find find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件. find的使用格式 ...

  4. scrapy微信爬虫使用总结

    scrapy+selenium+Chrome+微信公众号爬虫 概述 1.微信公众号爬虫思路: 参考:记一次微信公众号爬虫的经历 2.scrapy框架图 3.scrapy经典教程 参考: python ...

  5. 第 4 章—— C# 语言特性(《精通 ASP.NET MVC 5》)

    这里只提供各个特性的简单概括. C# 的完整指南可参阅<Introducing Visual C#>.深度了解 LINQ 可参考<Pro LINQ in C#> 4.1 准备示 ...

  6. JS获取昨天/今天/今年第一天的方法

    talk is cheap,show me the code! //获取昨天 var day1 = new Date(); day1.setTime(day1.getTime()-24*60*60*1 ...

  7. 猎豹浏览器(chrome内核)屏蔽视频广告

    1.基于猎豹浏览器(原则上chrome内核浏览器都可以) 2.下载插件Adblock Plus,下载地址:http://chromecj.com/productivity/2014-07/24/dow ...

  8. Android Mms专题之:Mms源码结构

    从软件的功能角度来讲,Mms分为对话列表,消息列表,短信编辑,彩信编辑,短信显示,彩信显示和配置. 从实现的角度来看,它分为GUI展示层,发送/接收,彩信解析,彩信附件,信息数据等,这些分类对应着源码 ...

  9. P2S、P2P、P2SP之对比

    P2S.P2P.P2SP之对比 一.下载原理分析 1.服务端下载技术(P2S):P2S下载方式分为HTTP与FTP两种类型,它们分别是Hyper Text Transportation Protoco ...

  10. HDU 1254 推箱子(BFS)

    Problem Description 推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不 ...