Jolt 变换 json - 如何添加默认字段
Jolt transform json - how to add default fields
我有以下输入 JSON
:
{
"id": "2ef8a2ee-054f-4b43-956a-8aa4f51a41d5",
"type": "VOICE",
"tags": [
{
"id": "some id 1",
"description": "some description 1"
},
{
"id": "some id 2",
"description": "some description 2"
}
],
"transcription": {
"key1": "val1",
"key2": "val2"
}
}
但是,输出 JSON
应该看起来类似,并且只添加默认值:
{
"id": "2ef8a2ee-054f-4b43-956a-8aa4f51a41d5",
"created": "2019-06-18T18:12:37",
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
"type": "VOICE",
"tags": [
{
"id": "some id 1",
"description": "some description 1"
},
{
"id": "some id 2",
"description": "some description 2"
}
],
"transcription": {
"key1": "val1",
"key2": "val2"
}
}
这是我的 JOLT
规格:
[
{
"operation": "shift",
"spec": {
}
},
{
"operation": "shift",
"spec": {
"*": {
"": "TRASH",
"*": {
"$": "&2"
}
}
}
},
{
"operation": "remove",
"spec": {
"TRASH": ""
}
},
{
"operation": "default",
"spec": {
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
}
}
]
我应该编辑 JOLT
规范,但我不明白如何(默认字段名字、姓氏和状态有效。创建的可以添加为 "created": "@(3,ninjaed-及时)"
如果您只想添加新字段,您只需使用如下 default
操作:
[
{
"operation": "default",
"spec": {
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
}
}
]
我有以下输入 JSON
:
{
"id": "2ef8a2ee-054f-4b43-956a-8aa4f51a41d5",
"type": "VOICE",
"tags": [
{
"id": "some id 1",
"description": "some description 1"
},
{
"id": "some id 2",
"description": "some description 2"
}
],
"transcription": {
"key1": "val1",
"key2": "val2"
}
}
但是,输出 JSON
应该看起来类似,并且只添加默认值:
{
"id": "2ef8a2ee-054f-4b43-956a-8aa4f51a41d5",
"created": "2019-06-18T18:12:37",
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
"type": "VOICE",
"tags": [
{
"id": "some id 1",
"description": "some description 1"
},
{
"id": "some id 2",
"description": "some description 2"
}
],
"transcription": {
"key1": "val1",
"key2": "val2"
}
}
这是我的 JOLT
规格:
[
{
"operation": "shift",
"spec": {
}
},
{
"operation": "shift",
"spec": {
"*": {
"": "TRASH",
"*": {
"$": "&2"
}
}
}
},
{
"operation": "remove",
"spec": {
"TRASH": ""
}
},
{
"operation": "default",
"spec": {
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
}
}
]
我应该编辑 JOLT
规范,但我不明白如何(默认字段名字、姓氏和状态有效。创建的可以添加为 "created": "@(3,ninjaed-及时)"
如果您只想添加新字段,您只需使用如下 default
操作:
[
{
"operation": "default",
"spec": {
"firstName": "Khusan",
"lastName": "Sharipov",
"status": "OPEN"
}
}
]