这是我的输入内容:
{ "isPoolPoint": "test", "timeZone": "ET" }
我希望输出为:
{ "address" : [{"line2": "test"}] }
如果isPoolPoint
是null
,我应该不会得到任何输出。
答案 0 :(得分:0)
规格
[
{
"operation": "shift",
"spec": {
"isPoolPoint": {
// match down into the values of "isPoolPoint"
// if we match null, then do nothing
"null": null,
// match everything else
"*": {
// write what was matched to the output
"$": "address[0].line2"
}
}
}
}
]
答案 1 :(得分:0)
I wanted to ignore blank strings as well in addition to null values so I did below extra condition
[
{
"operation": "shift",
"spec": {
"isPoolPoint": {
// OR operator below will care of empty string or null
"|null": null,
"*": {
"$": "address[0].line2"
}
}
}
}
]