An open API service indexing awesome lists of open source software.

https://github.com/xkcoding/simple-json

抽取一个简单 JSON 的通用接口,底层实现根据具体引入依赖指定。
https://github.com/xkcoding/simple-json

Last synced: 6 months ago
JSON representation

抽取一个简单 JSON 的通用接口,底层实现根据具体引入依赖指定。

Awesome Lists containing this project

README

          

Simple-JSON



Travis-CI
MAVEN
author
JDK
LICENSE

## 简介

> 抽取一个简单 JSON 的通用接口,底层实现根据具体引入依赖指定。

```xml

com.xkcoding.json
simple-json
0.0.3

```

## 特点

- 默认会按照下面的优先级自行寻找底层实现,`jackson -> fastjson -> gson -> hutool-json`
- 也可以自行实现 `com.xkcoding.json.support.JsonAdapter` 接口,通过 `JsonUtil.setJsonAdapter(new MyJsonImpl())` 设置进来

```java
JsonUtil.setConfig(JsonConfig.builder().dateFormat("yyyy-MM-dd HH:mm:ss").build());
String jsonStr=JsonUtil.toJsonString(obj);
System.out.println(jsonStr);

User user=JsonUtil.toBean(jsonStr,User.class);
System.out.println(user);

Map map=JsonUtil.toBean(jsonStr,Map.class);
System.out.println(map);

Kv kv=JsonUtil.parseKv(jsonStr);
```

## TODO

- [x] ~~抽取不同实现的 JSON 序列化/反序列配置~~
- [x] ~~优化KV体验~~(感谢[@亚东](https://github.com/zhangyd-c)的 [PR#1](https://github.com/xkcoding/simple-json/pull/1))
- [x] ~~支持 List 转化~~(感谢 [@青木](https://github.com/StringKe) 的 [PR#2](https://github.com/xkcoding/simple-json/pull/2))