https://github.com/xkcoding/simple-json
抽取一个简单 JSON 的通用接口,底层实现根据具体引入依赖指定。
https://github.com/xkcoding/simple-json
Last synced: 6 months ago
JSON representation
抽取一个简单 JSON 的通用接口,底层实现根据具体引入依赖指定。
- Host: GitHub
- URL: https://github.com/xkcoding/simple-json
- Owner: xkcoding
- License: lgpl-3.0
- Created: 2021-01-20T10:28:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-26T15:19:19.000Z (almost 3 years ago)
- Last Synced: 2025-07-04T00:03:36.845Z (6 months ago)
- Language: Java
- Size: 31.3 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple-JSON
## 简介
> 抽取一个简单 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))