如何在 json jolt 中用常数值替换值?
how to replace value with constant value in json jolt?
输入:
{
"locationId": 100212,
"weatherDateGmt": 1642590000,
"geoLocation": {
"latitude": 43.80306,
"longitude": 143.89083
},
"humidity": 77,
"currentCondition": "Mostly Clear",
"latitude": 43.80306,
"longitude": 143.89083
}
想要的输出:
"locationId": 100212,
"weatherDateGmt": 1642590000,
"humidity": 77,
"currentCondition": "Snow",
"latitude": 43.80306,
"longitude": 143.89083
我希望 "currentCondition"
始终是 "Snow"
而没有 geoLocation
这是我的震撼:
[
{
"operation": "shift",
"spec": {
"geoLocation": null,
"*": "&",
"currentCondition": {
"*": { "Snow": "currentCondition" }
}
}
}
]
这是我的输出:
{
"locationId" : 100212,
"weatherDateGmt" : 1642590000,
"humidity" : 77,
"latitude" : 43.80306,
"longitude" : 143.89083
}
currentCondition
已被删除,我该如何修复?
您可以通过 remove 转换删除这些属性("geoLocation"
和 "currentCondition"
),然后使用 #
符号和 shift变换如
[
{
"operation": "remove",
"spec": {
"geoLocation": "",
"currentCondition": ""
}
},
{
"operation": "shift",
"spec": {
"*": "&",
"#Snow": "currentCondition"
}
}
]
输入:
{
"locationId": 100212,
"weatherDateGmt": 1642590000,
"geoLocation": {
"latitude": 43.80306,
"longitude": 143.89083
},
"humidity": 77,
"currentCondition": "Mostly Clear",
"latitude": 43.80306,
"longitude": 143.89083
}
想要的输出:
"locationId": 100212,
"weatherDateGmt": 1642590000,
"humidity": 77,
"currentCondition": "Snow",
"latitude": 43.80306,
"longitude": 143.89083
我希望 "currentCondition"
始终是 "Snow"
而没有 geoLocation
这是我的震撼:
[
{
"operation": "shift",
"spec": {
"geoLocation": null,
"*": "&",
"currentCondition": {
"*": { "Snow": "currentCondition" }
}
}
}
]
这是我的输出:
{
"locationId" : 100212,
"weatherDateGmt" : 1642590000,
"humidity" : 77,
"latitude" : 43.80306,
"longitude" : 143.89083
}
currentCondition
已被删除,我该如何修复?
您可以通过 remove 转换删除这些属性("geoLocation"
和 "currentCondition"
),然后使用 #
符号和 shift变换如
[
{
"operation": "remove",
"spec": {
"geoLocation": "",
"currentCondition": ""
}
},
{
"operation": "shift",
"spec": {
"*": "&",
"#Snow": "currentCondition"
}
}
]