Package com.thoughtworks.xstream.io.json

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


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


    }

    protected XStream getXStream() throws Exception {
        XStream xstream;
        if (format.equals("json")) {
            xstream = new XStream(new JettisonMappedXmlDriver()) {
                protected MapperWrapper wrapMapper(MapperWrapper next) {
                    return new MapperWrapper(next) {
                        public boolean shouldSerializeMember(Class definedIn, String fieldName) {
                            return definedIn != Object.class && super.shouldSerializeMember(definedIn, fieldName);
                        }
View Full Code Here

public class JsonUtil {
 
  @SuppressWarnings("unchecked")
  public String toJson(Class classe, Object object) {
    XStream xstream = new XStream(new JettisonMappedXmlDriver());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("usuario", classe);
    return xstream.toXML(object);
  }
View Full Code Here

    return xstream.toXML(object);
  }
 
  @SuppressWarnings("unchecked")
  public Object fromJson(Class classe, String element) {
    XStream xstream = new XStream(new JettisonMappedXmlDriver());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias(classe.getSimpleName().toLowerCase(), classe);
    return xstream.fromXML(element);
  }
View Full Code Here

    }

    protected XStream getXStream() throws Exception {
        XStream xstream;
        if (format.equals("json")) {
            xstream = new XStream(new JettisonMappedXmlDriver()) {
                protected MapperWrapper wrapMapper(MapperWrapper next) {
                    return new MapperWrapper(next) {
                        public boolean shouldSerializeMember(Class definedIn, String fieldName) {
                            return definedIn != Object.class && super.shouldSerializeMember(definedIn, fieldName);
                        }
View Full Code Here

  /**
   * You can override this method for configuring Driver before serialization
   */
  protected HierarchicalStreamDriver getHierarchicalStreamDriver() {
    return new JettisonMappedXmlDriver();
  }
View Full Code Here

  }

  public void testStreamDriverTransform() throws Exception {
    XStreamMessageTransformer transformer = (XStreamMessageTransformer) createTransformer();
    transformer.setTransformType(ADAPTIVE);
    transformer.setStreamDriver(new JettisonMappedXmlDriver());
    connection = createConnection(transformer);

    // lets create the consumers
    Session adaptiveSession = connection.createSession(false,
        Session.AUTO_ACKNOWLEDGE);
View Full Code Here

    }
   
    public void testStreamDriverTransform() throws Exception {
      XStreamMessageTransformer transformer = new XStreamMessageTransformer(ADAPTIVE);
      transformer.setStreamDriver(new JettisonMappedXmlDriver());
        connectionFactory.setTransformer(transformer);
        connection = connectionFactory.createConnection();
        connection.start();

        // lets create the consumers
View Full Code Here

        case JMS_OBJECT_XML:
          in = new XppReader(new StringReader(text));
          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));
          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().endsWith("json")) {
      out = new JettisonMappedXmlDriver().createWriter(buffer);
    } else {
      out = new PrettyPrintWriter(buffer);
    }
    getXStream().marshal(object, out);
    return buffer.toString();
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.