【发布时间】:2022-01-11 12:29:22
【问题描述】:
我是 Mule 的新手,正在为一个场景苦苦挣扎。
Payload1 是从 csv 文件中检索的,payload2 是传入的有效负载; Payload2 可能有多个对象。输出字段需要根据payload1(即csv格式)和payload2的对应值进行排列。比较需要全部小写。
payload1 = "Name,Roll Number,Standard,Name of School,Address,Marks in Maths" //this is an input from a csv file
//below is the input from different payload which is in camelcase.
payload2 = [
{
"address": "Street 123",
"standard": "IV",
"marksInMaths": "90",
"rollNumber": "5",
"name": "XYZ",
"nameofSchool": "Best School"
}]
需要的输出:
[{
"Name" : "XYZ",
"Roll Number": "5",
"Standard" : "IV",
"Name of School": "Best School",
"Address": "Street 123",
"Marks in Maths": "90"
}]
我怎样才能做到这一点?
【问题讨论】:
-
我在尝试将 CSV 上的名称与 payload2 对象中的名称匹配时发现了一些问题。例如,
Name of School很容易转换为nameofSchool。但是要将Marks in Maths转换为marksInMaths,逻辑是不同的(除非是拼写错误)。如果是这种情况,您需要在某处获取有关名称映射的元数据。 -
嗨@JorgeGarcia 是的,这就是问题所在;这就是为什么我们需要将两者都转换为所有小写然后进行比较,只有这样它才会起作用
-
哦,我知道了。谢谢!