我有以下要求 这是我只需要允许statusEvent.type:“ Proof_approved”的输入 >
{
"statusEvent": {
"type": "PROOF_APPROVED",
"status": "WAITING_FOR_INPUT",
"eventDate": "2010-11-11T07:00:00Z",
"modifyDate": "2010-11-11T07:00:00Z",
"userName": "educator@school.edu (educator%40school.edu)",
"userOrgId": "1321231",
"quoteLineId":"testid1"
"packageConfiguration": [
{
"packageId": [
"AIM_PACKAGE1"
],
"component": [
"Handbook"
],
"fieldName": [
"Upload Handbook Document"
],
"assetUrl": [
"sflydamlocation.handbookfilename1.pdf"
]
}
]
}
}
输出类似:
(下面应仅是类型为“ type”的有效载荷:“ PROOF_APPROVED”,)
{
"name": payload.statusevent.userName,
"orderItems": [
{
"quoteLineId": payload.statusevent.quoteLineId,
"package": payload.statusevent.packageconfiguration
}
]
}
答案 0 :(得分:0)
如果输入的JSON是数组,则可以使用filter
来过滤记录。像这样:
%dw 2.0
output application/json
---
payload filter ($.statusEvent.'type'=="PROOF_APPROVED") map{
"quoteLineId": $.statusEvent.quoteLineId,
"package": $.statusEvent.packageConfiguration
}