我想使用Jolt处理器实现JSON转换。我的JSON中有null字段,我想删除所有这些字段...
{...............
"myValue": 345,
"colorValue": null,
"degreeDayValue": null,
"depthValue": null,
"distanceValue": null
...........}...to只保留myValue字段。
我可以使用Jolt操作remove来实现这一点吗?
发布于 2020-06-10 14:17:38
要从内部数组中删除null,请在末尾使用以下代码
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
}发布于 2018-03-24 11:12:26
这是可能的,只是不容易或简单。需要两个步骤。
等级库
[
{
"operation": "default",
"spec": {
// for all keys that have a null value
// replace that null value with a placeholder
"*": "PANTS"
}
},
{
"operation": "shift",
"spec": {
// match all keys
"*": {
// if the value of say "colorValue" is PANTS
// then, match but do nothing.
"PANTS": null,
// otherwise, any other values are ok
"*": {
// "recreate" the key and the non-PANTS value
// Write the value from 2 levels up the tree the "@1"
// to the key from 3 levels up the tree => "&2".
"@1": "&2"
}
}
}
}
]产生
{
"myValue" : 345
}https://stackoverflow.com/questions/49422252
复制相似问题