on 2018 Aug 15 8:59 AM
Friends, I have a requirement to convert any type of Models at run time to Xml in a generic way when the hybris application is running. This needs to be a a generic implementation for any type of Models to be converted ino XML. plz help.
I already tried below 3 approaches but failed:-
1>> JAXB - Can not handle any reference to Interfaces present as a type, inside the Model. 2>> Xstream conversion - But only generating Below xml but not the entire ItemModel(CartEntryModel).
convertToXml(ItemModel model)
{
XStream xstream = new XStream(new DomDriver());
String strXml = xstream.toXML(model);
return strXml;
}
Generated Xml:-
de.hybris.platform.core.model.order.CartEntryModel resolves-to="de.hybris.platform.servicelayer.model.strategies.SerializationStrategyLeanImpl$LeanItemModelHandler>
tenantID>master
primaryKey>8797895295020
de.hybris.platform.core.model.order.CartEntryModel>"
3>> ObjectMapper - This is failing for infiniteloop
ObjectMapper xmlMapper = new XmlMapper(); xmlMapper.writeValueAsString(ItemModel)
Request clarification before answering.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.