我有一个带有输入的json:
{
"customerId": "12345",
"customerStatusTrail": [
"INITIATED",
"PENDING",
"COMPLETED"
],
"segment": "S1"
}我想把它转换成:
{
"customerId": "12345",
"customerStatusTrail": "COMPLETED",
"segment": "S1"
}customerStatusTrail的列表并不总是大小为3的,它总是不同的。我想获取list的最后一个元素,并在输出中使用它。
我不确定JOLT中是否有这样的转换来获取list的最后一个元素。
发布于 2018-07-19 23:35:44
是的,像这样的JOLT是可能的
[
{
"operation": "modify-overwrite-beta",
"spec": {
"customerStatusTrail": "=lastElement(@(1,&))"
}
}
]有关更多默认方法,可以参考Jolt List functions
https://stackoverflow.com/questions/51204624
复制相似问题