如何使用 Jolt 更改大 Json 中的一个字段的名称
How to change a name of one field in large Json using Jolt
我有一个很大的Json文档:
{ "field1": "value1",
"field2": "value2",
"field3": "value3",
...
"field1000": "value1000"
}
我想将一个字段(field3)的名称更改为third_field
如何在不编写规范的情况下做到这一点:
[
{
"operation": "shift",
"spec": {
"field1": "field1",
"field2": "field2",
"field3": "third_field",
...
"field1000": "field1000"
}
}
]
这应该有效,并且本质上是 if then else
[
{
"operation": "shift",
"spec": {
//if
"field3": {
//$ - current value
"$": "third_field"
},
//else
"*": {
//$ - current value
//& - current key
"$": "&"
}
}
}
]
我有一个很大的Json文档:
{ "field1": "value1",
"field2": "value2",
"field3": "value3",
...
"field1000": "value1000"
}
我想将一个字段(field3)的名称更改为third_field
如何在不编写规范的情况下做到这一点:
[
{
"operation": "shift",
"spec": {
"field1": "field1",
"field2": "field2",
"field3": "third_field",
...
"field1000": "field1000"
}
}
]
这应该有效,并且本质上是 if then else
[
{
"operation": "shift",
"spec": {
//if
"field3": {
//$ - current value
"$": "third_field"
},
//else
"*": {
//$ - current value
//& - current key
"$": "&"
}
}
}
]