Best way to xml to object using Kotlin fasterxml

79 Views Asked by At
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dataset id="infoList">
        <rows>
            <row>
                <lvl>4</lvl>
                <itemCd>9999</itemCsfCd>
                <itemName>HELLO</itemCsfNm>
                <itemPrice>50</itemPrice>
            </row>
        </rows>
    </Dataset>
    <Dataset id="result">
        <rows>
            <row>
                <code>0000</code>
                <message>Success</message>
            </row>
        </rows>
    </Dataset>

There are two in different formats within the parent . Each Dataset is distinguished by its id property. I want to map this to an object using fasterxml.

I want to map it to

data class Response(
    val info: InfoDataset;

    val result: ResultDataset
)

not

data class Response(
    val datasetList: List<Dataset>
)

I tried

data class Response2XML(
    @JacksonXmlProperty(localName = "Dataset")
    val info: InfoDataset,

    @JacksonXmlProperty(localName = "Dataset")
    val result: ResultDataset
)

But Conflicting getter definitions for property "Dataset" error occured.

How do i solve this problem?

0

There are 0 best solutions below