n***@public.gmane.org
2011-12-16 18:18:16 UTC
I have two methods that handle the different XML and JSON submissions
to our server. When using the json, I need to pass in the class while
JAXB handles figuring out which class. Is there a way to pass in the
class as part of the json submission?
protected Object unmarshallBeanXML (InputStream istrm)
throws Exception
{
Unmarshaller umarsh = jc.createUnmarshaller ();
return xmlcommand = umarsh.unmarshal (istrm);
}
protected Object unmarshallBeanJson (InputStream istrm, Class
clazz)
throws Exception
{
JSONUnmarshaller umarsh =
((JSONJAXBContext)jc).getJSONUnmarshaller(jc.createUnmarshaller ());
return umarsh.unmarshalFromJSON (istrm, clazz);
}
example jaxb class.
@XmlRootElement(name = "login")
public class Login {
}
to our server. When using the json, I need to pass in the class while
JAXB handles figuring out which class. Is there a way to pass in the
class as part of the json submission?
protected Object unmarshallBeanXML (InputStream istrm)
throws Exception
{
Unmarshaller umarsh = jc.createUnmarshaller ();
return xmlcommand = umarsh.unmarshal (istrm);
}
protected Object unmarshallBeanJson (InputStream istrm, Class
clazz)
throws Exception
{
JSONUnmarshaller umarsh =
((JSONJAXBContext)jc).getJSONUnmarshaller(jc.createUnmarshaller ());
return umarsh.unmarshalFromJSON (istrm, clazz);
}
example jaxb class.
@XmlRootElement(name = "login")
public class Login {
}