EasyJson 发布
JSON库很常用了,现在开源的JSON库也有很多。但是我们仍然面临下列问题
1)时不时的爆出这个Json库出现漏洞,那个json库出现漏洞。一旦出现漏洞只能升级,想切换JSON都不成。
2)一个项目中有多个JSON库(这个原因很多,但又不可避免),改Bug可能都得学习多种JSON库
鉴于如上问题,开发了一套easyjson库,你可以把它看做是slf4j一样,它本身不做JSON的处理,可用它来讲任何的JSON进行适配到其他的JSON库上。
它是基于此思路开发出来的。使用它,你的现有项目不需要做一行的代码改变即可在各个JSON库自如的切换。
仓库地址:Github EasyJSON
关键特性:
- Supports gson, fastjson, jackson, Progsbase ...
- Supports tree model, stream model
- Control whether serialize null
- Convert ON|OFF, 1|0 to Boolean
- Serialize or deserialize a Enum based on custom field
- Serialize or deserialize a Date using specified pattern | date format
- Supports custom exclusion rule, for examples: @Ignore, transient, specified modifier ...
- Get the JSONBuilder with zero configuration
- Switch the underlying implement without any code change
- Supports JDK 1.6+
目前支持将JSON库适配给fastjson, gson, jackason
easyjson facade | JSON Implementation |
---|---|
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>easyjson-core</artifactId> <version>${version}/version> </dependency> |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>easyjson-gson</artifactId> <version>${version}/version> </dependency> <dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>easyjson-jackson</artifactId> <version>${version}/version> </dependency> <dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>easyjson-fastjson</artifactId> <version>${version}/version> </dependency> |
同时也支持将这些JSON通过easyjson 适配:
JSON Library | Maven | version | Adapter |
---|---|---|---|
Android json |
<dependency> <groupId>com.vaadin.external.google</groupId> <artifactId>android-json</artifactId> <version>0.0.20131108.vaadin1</version> </dependency> |
0.0.20131108.vaadin |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>android-to-easyjson</artifactId> <version>${version}</version> </dependency> |
fastjson |
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.58</version> </dependency> |
1.2.58 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>fastjson-to-easyjson</artifactId> <version>${version}</version> </dependency> |
json-lib |
<dependency> <groupId>com.hynnet</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> </dependency> |
2.4 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>jsonlib-to-easyjson</artifactId> <version>${version}</version> </dependency> |
json-smart |
<dependency> <groupId>net.minidev</groupId> <artifactId>json-smart</artifactId> <version>2.3</version> </dependency> |
2.3 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>jsonsmart-to-easyjson</artifactId> <version>${version}</version> </dependency> |
Eclipse minimal-json |
<dependency> <groupId>com.eclipsesource.minimal-json</groupId> <artifactId>minimal-json</artifactId> <version>0.9.5</version> </dependency> |
0.9.5 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>minimaljson-to-easyjson</artifactId> <version>${version}</version> </dependency> |
org.json |
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180813</version> </dependency> |
20180813 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>orgjson-to-easyjson</artifactId> <version>${version}</version> </dependency> |
Progsbase JSON |
<dependency> <groupId>com.progsbase.libraries</groupId> <artifactId>JSON</artifactId> <version>0.3.9</version> </dependency> |
0.3.9 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>progsbase-to-easyjson</artifactId> <version>${version}</version> </dependency> |
json-simple |
<dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> |
1.1.1 |
<dependency> <groupId>com.github.fangjinuo.easyjson</groupId> <artifactId>simplejson-to-easyjson</artifactId> <version>${version}</version> </dependency> |
作者: 房继诺
出处:http://www.cnblogs.com/f1194361820
版权:本文版权归作者和博客园共有
欢迎转载,转载请需要注明博客出处
技术交流QQ:1194361820,加好友请注明:来自博客园,不要说你是博客园,也可以扫描图像二维码直接加我。