English 中文(简体)
需要在数据Wave 2.0 建造JSON有效载荷
原标题:Need help in constructing JSON Payload in DataWeave 2.0

我在投入有效载荷以下有2个,我需要用这些有效载荷来建造第3号有效载荷如下所示。 有效载荷第2号是所有领域的数据信息。

<><>>

The fields in this payload change for every employee, the below payload has only 2 fields


页: 1
  "employee": [
    页: 1
      "Employee_Number": "123456",
      "Country_of_Birth": "USA",
    iii
  ]
iii

<><>Payload #2:

(this holds meta data kind of information which needs to be referred from payload # 3 for constructing the payload # 3). For instance, for the Employee_Number from payload # 1, the meta data info needs to pulled from Payload # 2 and for all the other respective fields from payload # 1 accordingly.


[
  页: 1
    "employeeMetaColumn": "Employee_Number",
    "employeeMetaText": "Employee Number",
    "employeeMetaType": "SECT",
    "employeeMetaId": 435
  iii,
  页: 1
    "employeeMetaColumn": "Country_of_Birth",
    "employeeMetaText": "Country of Birth",
    "employeeMetaType": "SECT",
    "employeeMetaId": 345
  iii,
  页: 1
    "employeeMetaColumn": "Years_Completed",
    "employeeMetaText": "Years Completed",
    "employeeMetaType": "FLD",
    "employeeMetaId": 427
  iii,
  页: 1
    "employeeMetaColumn": "First_Name",
    "employeeMetaText": "First Name",
    "employeeMetaType": "SECT",
    "employeeMetaId": 998
  iii
]

Payload # 3

拟建的最终有效载荷


页: 1

"parameters": [页: 1
        "employeeParamValue": [
            "123456"
        ],
        "employeeMetaColumn": "Employee_Number",
        "employeeMetaText": "Employee Number",
        "employeeMetaType": "SECT",
        "employeeMetaId": 435,
        
    iii,
    页: 1
        "employeeParamValue": [
            "USA"
        ],
        "employeeMetaColumn": "Country_of_Birth",
        "employeeMetaText": "Country of Birth",
        "employeeMetaType": "SECT"
        "employeeMetaId": 345,
    iii
]

iii

问题回答

问题不明确,但我作了受过教育的猜测,不应将有效载荷的价值图上的结果从产出中抹去。 其余部分只是按每条<代码>的数值(>employeeMetaColumn至的数值(<=1>)。 我还不得不假设,阵列<代码>有效载1.employee 面积 1. 我的文字<代码>有效载荷 包含<代码>有效载荷2和 有效载荷1的价值是一个变量。

%dw 2.0
output application/json
var payload1={
  "employee": [
    {
      "Employee_Number": "123456",
      "Country_of_Birth": "USA",
    }
  ]
}
---
payload 
    map {
        employeeParamValue: [payload1.employee[0][$.employeeMetaColumn]],
        ($)
    }
    filter ($.employeeParamValue[0] != null)

产出:

[
  {
    "employeeParamValue": [
      "123456"
    ],
    "employeeMetaColumn": "Employee_Number",
    "employeeMetaText": "Employee Number",
    "employeeMetaType": "SECT",
    "employeeMetaId": 435
  },
  {
    "employeeParamValue": [
      "USA"
    ],
    "employeeMetaColumn": "Country_of_Birth",
    "employeeMetaText": "Country of Birth",
    "employeeMetaType": "SECT",
    "employeeMetaId": 345
  }
]

我不理解为什么<代码>employeeParamValue是一个阵列。 这似乎没有什么意义,因为它必须具有单一价值。





相关问题
How to compare two dates with only month and year in mule

My scenario is to check if the Month and year (in date value) is less than the current month and year (in current date value). The condition I need to implement is this if source-month&year < ...

需要在数据Wave 2.0 建造JSON有效载荷

我在投入有效载荷以下有2个,我需要用这些有效载荷来建造第3号有效载荷如下所示。 有效载荷第2号是所有领域的数据信息。

Json to Rainbow in Dataweave 2.0

我正试图将一个json阵列转换到(以表格格式)在MuleSoft使用2.0数据。 我的投入有效载荷就是这样:

Convert java.sql.timestamp to DateTime in Dataweave

I am getting a java.sql.Timestamp from a database request. This value indicates an instant in time so timezone is not relevant (for that matter java.sql.Timestamp does not have a timezone, as it ...

热门标签