简体   繁体   中英

Show input field names from Java Map while mapping to new JSON object in Dataweave

I am using Anypoint Studio 6.1 with Mule 3.8.1 and I have a csv file that I have converted to java using Dataweave. Later in the workflow I have to perform a new mapping to the output JSON object using Dataweave.

I have a number of fields to map so wanted to find out if there is there a way of showing the fields in the Java input in the left side input panel so I can use the graphical GUI to map?

The code I am using to convert the csv to java in Dataweave is:

%dw 1.0
%input payload application/csv
%output application/java
---
payload

Thanks

You have to define metadata in configuration of transform component.

Follow the sequence

  1. Click on define metdata

    点击定义元数据

  2. Add type id (any name)

    在任何名称中添加类型ID

  3. Select type.

    选择类型

  4. Select java object type.

    选择Java对象类型

  5. Type qualified name of class.

    找到你的班级

To add to Beacon's response..after you follow those instructions you can right click on the payload -> Edit Sample Data and then add your sample/mock up java object info following

The input java class (follows TheBeacon's instructions):

package org.example;
    public class Name {
       String first;
       String last;

    public Name() {};

    public void setFirst(String first){
       this.first = first;
    }
    public void getFirst(){
       return first;
    }
    public setLast(String last){
       this.last = last;
    }

    public getLast() {
      return last;
    }
    }

Then your DW input side example would look like:

%dw 1.0
%output application/java
---
{
    first: 'Jane',
    last: 'Doe'    
} as :object {
    class : "org.example.Name"
}

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