Hi,
I'm trying to unmarshal a json  into a Java object using JSONProvider.
However, in the unmarshalled object, I'm not getting all the elements
unmarshalled into the list property.

*JSON used:*
{
    "Header": {
        "ProductIdentifier": "WLW",
        "Version": "2"
    },

    "Keys":[{"RegistrationKey":"1234567abcd"}, {"RegistrationKey":"789xyz"}]
}

*My jsonProvider spring configuration:*
    <bean class="org.apache.cxf.jaxrs.provider.JSONProvider">
        <property name="inTransformElements">
            <map>
                <entry key="*" value="{Mynamespace}*" />
            </map>
        </property>
        <property name="supportUnwrapped" value="true" />
    </bean>

*JAXB annotations for the top element*
//removed annotations for readability
public class ClientRequest {

    @XmlElement(name = "Header", namespace = "Mynamespace")
    private ReqHeader header;

    @XmlElementWrapper(name="Keys", namespace = "Mynamespace")
    @XmlElement(name="RegistrationKey", namespace = "Mynamespace")
    private List<String> keys = new ArrayList<String>();
}

*code for unmarshalling:*
Object  obj = jsonProvider.readFrom((Class)ClientRequest.class, null, null,
null, null, inputStream);

In the unmarshalled object, the keys property is being mapped as arraylist
but with only one element, the last element("789xyz").
If I interchange the order of the RegistrationKey elements, then the other
key(1234567abcd) is being mapped. So, the size of the keys arraylist is 1.
I was expecting the size of keys to be 2 as you can see in json there are
two RegistrationKey elements.

Can someone please help me, if I've missed any configuration of jaxb or
jsonprovider?

Thanks,
Kiran Sireesh




--
View this message in context: 
http://cxf.547215.n5.nabble.com/JSONProvider-unable-to-unmarshal-json-containing-list-of-elements-tp5715651.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to