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 ...
随机推荐
- android--------动画之进度条
Android开发中在处理耗时工作的时候,例如:列表加载,大多数会有一个精度条加载的框,里面有一个像gif的图片在旋转一样. 效果图: <!-- 根标签为animation-list ...
- hdu-5492-dp
Find a path Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- python中字符串连接的四种方式
以下实例展示了join()的使用方法 #!/usr/bin/python str = "-"; seq = ("a", "b", " ...
- spring boot 学习(十四)SpringBoot+Redis+SpringSession缓存之实战
SpringBoot + Redis +SpringSession 缓存之实战 前言 前几天,从师兄那儿了解到EhCache是进程内的缓存框架,虽然它已经提供了集群环境下的缓存同步策略,这种同步仍然需 ...
- 015PHP文件处理——文件处理flock 文件锁定 pathinfo realpath tmpfile tempname
<?php /**文件处理flock 文件锁定 pathinfo realpath tmpfile tempname */ /*$arr=pathinfo('ab.txt');//获取文件路径的 ...
- 快速切题 sgu103. Traffic Lights 最短路 难度:1
103. Traffic Lights Time limit per test: 0.25 second(s)Memory limit: 4096 kilobytes input: standardo ...
- vue-router如何做历史返回提示?
获取vue-router的上一个页面是否存在或者是否是自己需要返回的地址,可以使用vue-router的的声明周期函数,有三种模式: 第一种.使用全局函数beforeEach,直接来获取form.pa ...
- 用正则表达式匹配用rdf3x处理过后的TTL格式文档
1.比如下面这个用rdf3x处理过后的TTL文档片段: 注意缩进的是两个空格 <http://rdf.ebi.ac.uk/resource/chembl/target/CHEMBL2363853 ...
- Java——File类成员方法
body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...
- numpy 小示例
import numpy as np 生成 3*4 的由 0 组成的二维数组 >>> np.zeros((3,4)) array([[0., 0., 0., 0.], [0., 0 ...