Json.NET Updates: Merge, Dependency Injection, F# and JSONPath Support
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的更多相关文章
- 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 ...
- [转载][翻译] IoC 容器和 Dependency Injection 模式
原文地址:Inversion of Control Containers and the Dependency Injection pattern 中文翻译版本是网上的PDF文档,发布在这里仅为方便查 ...
- Srping - bean的依赖注入(Dependency injection)
目录 1 概述 2 两种基本的依赖注入方式 2.1 构造函数方式 2.2Setter方式 3 其他依赖注入功能 3.1 <ref/>标签引用不同范围的bean 3.2 内部bean 3.3 ...
- [Angular] Component's dependency injection
An Angular service registered on the NgModule is globally visible on the entire application. Moreove ...
- Ninject学习(一) - Dependency Injection By Hand
大体上是把官网上的翻译下而已. http://www.ninject.90iogjkdcrorg/wiki.html Dependency Injection By Hand So what's Ni ...
- MVC Controller Dependency Injection for Beginners【翻译】
在codeproject看到一篇文章,群里的一个朋友要帮忙我翻译一下顺便贴出来,这篇文章适合新手,也算是对MEF的一个简单用法的介绍. Introduction In a simple stateme ...
- 控制反转Inversion of Control (IoC) 与 依赖注入Dependency Injection (DI)
控制反转和依赖注入 控制反转和依赖注入是两个密不可分的方法用来分离你应用程序中的依赖性.控制反转Inversion of Control (IoC) 意味着一个对象不会新创建一个对象并依赖着它来完成工 ...
- Dependency Injection
Inversion of Control - Dependency Injection - Dependency Lookup loose coupling/maintainability/ late ...
- 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 ...
随机推荐
- AC自动机技巧
AC自动机技巧 可以用树上的一些算法来进行优化 对于要求支持插入和删除字符串的题目,可以通过建两个AC自动机,查询的时候作差来实现. 当给出的查询串是一个含有空格的文本时,可以用特殊字符(比如'z'+ ...
- Nginx+uWsgi生产部署Django
部署得过程很简单,部署得核心在于,为什么要这样做,每一个参数代表什么意思,最终的目的是得了解,一些基概念性的东西. uWsgi简介 说Uwsgi之前,先说一下Wsgi. 什么是Wsgi? WSGI: ...
- Sasha and Interesting Fact from Graph Theory CodeForces - 1109D (图论,计数,Caylay定理)
大意: 求a->b最短路长度为m的n节点树的个数, 边权全部不超过m 枚举$a$与$b$之间的边数, 再由拓展$Caylay$定理分配其余结点 拓展$Caylay$定理 $n$个有标号节点生成k ...
- Leetcode 89
回溯写到自闭:不想就删了: class Solution { public: vector<int> grayCode(int n) { vector<vector<int&g ...
- Linux文件与目录管理(二)
一.处理目录的常用命令 ls:列出目录 cd:切换目录 pwd:显示当前的目录 mkdir:创建一个新的目录 rmdir:删除一个空的目录 cp:复制文件或者目录 rm:移除文件或者目录 可以使用ma ...
- oracle12c中新能优化新特性之热度图和自动数据优化
1. Oracle12c热度图和自动数据优化 信息生命周期管理(ILM)是指在数据生命周期内管理它们的策略.依赖于数据的年龄和对应用的业务相关性,数据能被压缩,能被归档或移到低成本的存储上.简言之,I ...
- (C#基础) ref 和out练习
对于C#中这两个关键字的用法,常常混淆,有点不清楚,今天又一次看到.遂把它们都记录下来,希望能有所用.这些都是他人写的,我只是搬过来一次,加深印象. 代码 using System; using Sy ...
- 做了一个vue的同步tree 的npm组件包
前言:因为现成的tree组件没有找到.亦或是其依赖的其他东西太多,不太合适引入我们的项目,所以自己做了一个.大概样式: 在线例子: https://hamupp.github.io/t-vue-tre ...
- ant 打 jar 包添加 manifest.mf 文件
经查询 ant 有 <manifest> 任务可以创建 manifest文件(https://ant.apache.org/manual/Tasks/manifest.html) 但尝试在 ...
- 再谈Contacts中姓氏多音字排序错误问题
说到中国人的名字,那就不得不考虑多音字的问题,比如'单',在作为姓氏时应该读作'shan'而不是'dan'.但是在Contacts程序中却使用的是'D'来作为bucket label!这是为什么?如何 ...