Hi 

I am trying to do xml to pojo deserialization.
My xml looks like below

<?xml version="1.0" encoding="UTF-8"?>
<DataApi xmlns="http://www.xxx.com/xs/DataApi/1.0";>

<Photo id="xyq3994">
    <Sizes>
         <Size id="sampe1" url="http://www.sampesite.com"/>
         <Size id="sample2" url="http://sampesite.com"/>
    </Sizes>
</Photo>
</DataApi>


I have written pojo classes for the same


@Getter
@Setter
public class DataApi {

private Photo photo;
}

@Getter
@Setter
public class Photo {

private Sizes sizes;
private String id;
}

@Getter
@Setter

public class Sizes {

private List<Size> size;
}

@Getter
@Setter
public class Size {

private String id;
private String url;
}


My mapper looks like below:

public static Object getResponseXML(String responseString, Class 
responseClass) throws IOException {

ObjectMapper xmlMapper = new XmlMapper();
xmlMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
return xmlMapper.readValue(responseString, responseClass);
}


@Test
public void test() {
DataApi dataApi= (DataApi) getResponseXML(response.asString(), 
DataApi.class);

dataApi. getPhoto().getSizes().getSize().get(0);  
}

I am getting IndexOutOfBoundException. And the list is not mapped to size 
on deserialization.

Can someone pls guide me what am I missing here.

I am using 2.12.2 version  com.fasterxml.jackson


Regards,

Aswathy

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/9cbf1099-b929-4ada-996e-200f146d4c8an%40googlegroups.com.

Reply via email to