Skip to main content

Posts

Showing posts with the label marshalling

Problem unmarshalling parcelables

I've got a few classes that implement Parcelable and some of these classes contain each other as properties. I'm marshalling the classes into a Parcel to pass them between activities. Marshalling them TO the Parcel works fine, but when I try to unmarshall them I get the following error:

Unmarshalling returned null object from a successfully marshalled XML

i have the following classes which is marshalled as an XML <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customer id="100"> <age>21</age> <hobbies> <hobby> <cost>sd</cost> <name>na</name> </hobby> <hobby> <cost>sd</cost> <name>nb</name> </hobby> </hobbies> <name>test</name> </customer> However, when i tried to unmarshall, I can only create the customer object but not hobby, which returns null Am i doing something wrong here? The problem seems to be with the XML hierarchy? package com.mytest.jxb; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEle