在 DataWeave 中删除包含 '\' 的 id
To remove id that contains '\' in DataWeave
输入
{
"phone": [
{
"id": "r/2",
"time": "2020-01-01"
},
{
"id": "31",
"time": "2020-02-21"
},
{
"id": "244",
"time": "2020-01-16"
}
]
}
所需输出: 按日期范围过滤,然后删除包含“/”的 ID
[244]
尝试:我设法过滤了日期,但没有删除包含“/”的 ID
(payload.phone filter ($.time >= "2020-01-01" and $.time <= "2020-01-21")).id distinctBy $
我使用了函数以便于重用:
%dw 2.0
output application/json
fun filterDateRanges(a, dateStart, dateEnd) = a filter ($.time >= dateStart and $.time <= dateEnd)
fun filterIdChar(a, c)=a filter !($.id contains c)
---
filterDateRanges(filterIdChar(payload.phone, "/"), "2020-01-01", "2020-01-21").id distinctBy $
输入
{
"phone": [
{
"id": "r/2",
"time": "2020-01-01"
},
{
"id": "31",
"time": "2020-02-21"
},
{
"id": "244",
"time": "2020-01-16"
}
]
}
所需输出: 按日期范围过滤,然后删除包含“/”的 ID
[244]
尝试:我设法过滤了日期,但没有删除包含“/”的 ID
(payload.phone filter ($.time >= "2020-01-01" and $.time <= "2020-01-21")).id distinctBy $
我使用了函数以便于重用:
%dw 2.0
output application/json
fun filterDateRanges(a, dateStart, dateEnd) = a filter ($.time >= dateStart and $.time <= dateEnd)
fun filterIdChar(a, c)=a filter !($.id contains c)
---
filterDateRanges(filterIdChar(payload.phone, "/"), "2020-01-01", "2020-01-21").id distinctBy $