简介:一个能够通过JSON配置(特定的语法)来处理复杂数据转换的工具。
比如将API响应转换为内部系统所需的格式,或者处理来自不同来源的数据结构差异。例如,将嵌套的JSON结构扁平化,或者重命名字段,合并多个字段等。
名称含义:
-
JSON + Bolt:
JSON 是工具处理的数据格式。
Bolt(闪电)象征快速和高效,暗示 Jolt 能够像闪电一样快速完成 JSON 数据的转换。
Bolt的logo就是一个闪电⚡️标志 -
在社区中,Jolt 的名称被解读为 JSON Transformation Language 的缩写,强调其作为 JSON 转换语言的定位。
使用
1. 引入maven依赖
- pom.xml
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>jolt-core</artifactId>
<version>0.1.7</version>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>json-utils</artifactId>
<version>0.1.7</version>
</dependency>
2. 编写Jolt转换规范(json格式)
- spec.json
[
{
"operation": "shift",
"spec": {
"id": "id",
"orderType": "type",
"orderProductList": {
"*": {
"sampleNumber": "orderProductList[&1].number",
"id": "orderProductList[&1].id"
}
},
"createTime"