use of com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver in project spring-framework by spring-projects.
the class XStreamMarshallerTests method jettisonDriver.
@Test
public void jettisonDriver() throws Exception {
marshaller.setStreamDriver(new JettisonMappedXmlDriver());
Writer writer = new StringWriter();
marshaller.marshal(flight, new StreamResult(writer));
assertEquals("Invalid result", "{\"flight\":{\"flightNumber\":42}}", writer.toString());
Object o = marshaller.unmarshal(new StreamSource(new StringReader(writer.toString())));
assertTrue("Unmarshalled object is not Flights", o instanceof Flight);
Flight unflight = (Flight) o;
assertNotNull("Flight is null", unflight);
assertEquals("Number is invalid", 42L, unflight.getFlightNumber());
}
use of com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver in project drools by kiegroup.
the class XStreamJSon method newJSonMarshaller.
public static XStream newJSonMarshaller() {
JettisonMappedXmlDriver jet = new JettisonMappedXmlDriver();
XStream xstream = createTrustingXStream(jet);
XStreamHelper.setAliases(xstream);
xstream.alias("commands", CommandsObjectContainer.class);
xstream.alias("objects", ObjectsObjectContainer.class);
xstream.alias("item", RowItemContainer.class);
xstream.alias("parameters", ParameterContainer.class);
xstream.alias("results", WorkItemResultsContainer.class);
xstream.setMode(XStream.NO_REFERENCES);
xstream.registerConverter(new JSonFactHandleConverter(xstream));
xstream.registerConverter(new JSonBatchExecutionResultConverter(xstream));
xstream.registerConverter(new JSonInsertConverter(xstream));
xstream.registerConverter(new JSonFireAllRulesConverter(xstream));
xstream.registerConverter(new JSonBatchExecutionCommandConverter(xstream));
xstream.registerConverter(new CommandsContainerConverter(xstream));
xstream.registerConverter(new JSonGetObjectConverter(xstream));
xstream.registerConverter(new JSonRetractConverter(xstream));
xstream.registerConverter(new JSonModifyConverter(xstream));
xstream.registerConverter(new JSonSetGlobalConverter(xstream));
xstream.registerConverter(new JSonInsertElementsConverter(xstream));
xstream.registerConverter(new JSonGetGlobalConverter(xstream));
xstream.registerConverter(new JSonGetObjectsConverter(xstream));
xstream.registerConverter(new JSonQueryConverter(xstream));
xstream.registerConverter(new JSonQueryResultsConverter(xstream));
xstream.registerConverter(new RowItemConverter(xstream));
xstream.registerConverter(new JSonStartProcessConvert(xstream));
xstream.registerConverter(new JSonSignalEventConverter(xstream));
xstream.registerConverter(new JSonCompleteWorkItemConverter(xstream));
xstream.registerConverter(new JSonAbortWorkItemConverter(xstream));
xstream.registerConverter(new JSonGetSessionTimeConverter(xstream));
xstream.registerConverter(new JSonAdvanceSessionTimeConverter(xstream));
return xstream;
}
Aggregations