Search code examples
javadozer

Mapping an Object[] with dozer


With the help of Dozer I want to map an Object[] to a DTO class

<mapping>
    <class-a>com.example.myDtoClass</class-a>
    <class-b>java.lang.Object[]</class-b>
    <field>
        <a>prop</a>
            <!-- <b key="1">this</b> -->
        <b>this[1]</b>
        <b-hint>java.lang.String</b-hint>
    </field>
</mapping>

but both settings <b>this[1]</b> and <b key="1">this</b> do not work and the prop field is set with the entire Object[] field so the result in returned JSON looks like

"prop": "[Ljava.lang.Object;@40147864"

what am I missing? I am expecting to have the 1 element of the Object[] in the prop variable


Solution

  • I made a bad mistake. Yes I get a Object[] to map, but the 1 element of that Object[] again is of type Object[]. I got confused and thought it was the main element. I did though expect a String, but got a array of binary code that has to be joined back to a string.