从 dataweave 2.0 中的 JSON 消息中提取 Max/earliest 日期
Extract Max/earliest date from JSON message in dataweave 2.0
我的消息结构:
{
"empid": "abc",
"homeCountry": "IND",
"dateOfBirth": "1969-01-01",
"personalInformation": [
{
"salutation": "Mr",
"firstName": "Ram",
"lastName": "Naresh"
}
],
"EmpInfo": [
{
"hireDate": "2000-01-01",
"LevDate": "2018-07-25",
"jobInformation": [
{
"isFullTimeEmployee": true,
"jobTitle": "Engineer",
"effectiveStartDate": "2018-01-05"
},
{
"isFullTimeEmployee": true,
"jobTitle": "Store Manager",
"effectiveStartDate": "2019-01-05"
}
]
}
]
}
我想提取相同的最大日期和索引,以便我可以将其声明为 var 并在映射中使用它。
你的问题不够明确。您要使用什么日期字段?
在这里我创建了一个解决方案,returns 索引和 jobInformation
的值与最旧的 effectiveStartDate
payload.EmpInfo[0].jobInformation
map ((item, index) -> {value: item, index: index})
maxBy ((item) -> item.value.effectiveStartDate as Date)
我的消息结构:
{
"empid": "abc",
"homeCountry": "IND",
"dateOfBirth": "1969-01-01",
"personalInformation": [
{
"salutation": "Mr",
"firstName": "Ram",
"lastName": "Naresh"
}
],
"EmpInfo": [
{
"hireDate": "2000-01-01",
"LevDate": "2018-07-25",
"jobInformation": [
{
"isFullTimeEmployee": true,
"jobTitle": "Engineer",
"effectiveStartDate": "2018-01-05"
},
{
"isFullTimeEmployee": true,
"jobTitle": "Store Manager",
"effectiveStartDate": "2019-01-05"
}
]
}
]
}
我想提取相同的最大日期和索引,以便我可以将其声明为 var 并在映射中使用它。
你的问题不够明确。您要使用什么日期字段?
在这里我创建了一个解决方案,returns 索引和 jobInformation
的值与最旧的 effectiveStartDate
payload.EmpInfo[0].jobInformation
map ((item, index) -> {value: item, index: index})
maxBy ((item) -> item.value.effectiveStartDate as Date)