简体   繁体   中英

Mule ESB 3.8 json output dw Script

I have the input json like this:

 {
      "person": {
        "personinfo": [
          {
            "VAR_KEY": "name",
            "VAR_VAL": "jack"
          },
          {
            "VAR_KEY": "sex",
            "VAR_VAL": "male"
          }
        ]
      }
    }

and I want to get the output like this

{
          "person": {
            "personinfo": [
              {
                "name":"jack"
              },
              {
                "sex":"male"
              }
            ]
          }
        }

how to write the mule esb dw script? thank you

this works for me

%dw 1.0
%output application/json
---
person : {
    personinfo : payload.person.personinfo map {
       ($.VAR_KEY) : $.VAR_VAL
}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM