Package com.thoughtworks.xstream.io.json

Examples of com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver


    }

    protected XStream getXStream() throws Exception {
        XStream xstream;
        if (format.equals("json")) {
            xstream = new XStream(new JettisonMappedXmlDriver());
        } else if (format.equals("xml")) {
            xstream = new XStream();
        } else {
            throw new Exception("Unknown format: " + format);
        }
View Full Code Here


                case JMS_OBJECT_XML:
                    in = new XppReader(new StringReader(text), XppFactory.createDefaultParser());
                    msg = createObjectMessage(in);
                    break;
                case JMS_OBJECT_JSON:
                    in = new JettisonMappedXmlDriver().createReader(new StringReader(text));
                    msg = createObjectMessage(in);
                    break;
                case JMS_MAP_XML:
                    in = new XppReader(new StringReader(text), XppFactory.createDefaultParser());
                    msg = createMapMessage(in);
                    break;
                case JMS_MAP_JSON:
                    in = new JettisonMappedXmlDriver().createReader(new StringReader(text));
                    msg = createMapMessage(in);
                    break;
                default:
                    throw new Exception("Unkown transformation: " + transformation);
                }
View Full Code Here

    protected String marshall(Serializable object, String transformation)
            throws JMSException {
        StringWriter buffer = new StringWriter();
        HierarchicalStreamWriter out;
        if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) {
            out = new JettisonMappedXmlDriver(new Configuration(), false).createWriter(buffer);
        } else {
            out = new PrettyPrintWriter(buffer);
        }
        getXStream().marshal(object, out);
        return buffer.toString();
View Full Code Here

    protected String marshallAdvisory(final DataStructure ds, String transformation) {

        StringWriter buffer = new StringWriter();
        HierarchicalStreamWriter out;
        if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) {
            out = new JettisonMappedXmlDriver().createWriter(buffer);
        } else {
            out = new PrettyPrintWriter(buffer);
        }

        XStream xstream = getXStream();
View Full Code Here

    assertXpathExists("/flights/string", result);
  }

  @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);
View Full Code Here

import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.mapper.Mapper;

public class XStreamJSon {
    public static XStream newJSonMarshaller() {
        JettisonMappedXmlDriver jet = new JettisonMappedXmlDriver();
        XStream xstream = new XStream( jet );

        XStreamHelper.setAliases( xstream );

        xstream.alias( "commands",
View Full Code Here

import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.mapper.Mapper;

public class XStreamJSon {
    public static XStream newJSonMarshaller() {
        JettisonMappedXmlDriver jet = new JettisonMappedXmlDriver();
        XStream xstream = new XStream( jet );

        XStreamHelper.setAliases( xstream );

        xstream.alias( "commands",
View Full Code Here

        // create OBError and serizalize it using JSON
        OBError error = new OBError();
        error.setType("Error");
        error.setTitle("Error");
        error.setMessage(strResult);
        XStream xs = new XStream(new JettisonMappedXmlDriver());
        xs.alias("OBError", OBError.class);
        strResult = xs.toXML(error);
      }

      out.print(strResult);
View Full Code Here

  /**
   * @return a JSON string representation of this obContext
   */
  public String toString() {
    XStream xstream = new XStream(new JettisonMappedXmlDriver());
    return xstream.toXML(this);
  }
View Full Code Here

   */
  public synchronized static ProcessContext newInstance(String arg0) {
    if (arg0 == null || arg0.trim().equals("")) {
      return null;
    }
    XStream xstream = new XStream(new JettisonMappedXmlDriver());
    return (ProcessContext) xstream.fromXML(arg0);
  }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.