Package de.odysseus.staxon.json

Examples of de.odysseus.staxon.json.JsonXMLOutputFactory.createXMLEventWriter()


    StringReader input = new StringReader("<alice><bob>charlie</bob></alice>");
    StringWriter output = new StringWriter();
    XMLEventReader reader = XMLInputFactory.newFactory().createXMLEventReader(input);
    XMLOutputFactory factory = new JsonXMLOutputFactory();
    factory.setProperty(JsonXMLOutputFactory.PROP_MULTIPLE_PI, true);
    XMLEventWriter writer = factory.createXMLEventWriter(output);
    writer = new XMLMultipleEventWriter(writer, true, "/alice/bob");
    writer.add(reader);
    writer.close();
    Assert.assertEquals("{\"alice\":{\"bob\":[\"charlie\"]}}", output.toString());
  }
View Full Code Here


    StringReader input = new StringReader("<alice><bob>charlie</bob></alice>");
    StringWriter output = new StringWriter();
    XMLEventReader reader = XMLInputFactory.newFactory().createXMLEventReader(input);
    XMLOutputFactory factory = new JsonXMLOutputFactory();
    factory.setProperty(JsonXMLOutputFactory.PROP_MULTIPLE_PI, true);
    XMLEventWriter writer = factory.createXMLEventWriter(output);
    writer = new XMLMultipleEventWriter(writer, false, "/bob");
    writer.add(reader);
    writer.close();
    Assert.assertEquals("{\"alice\":{\"bob\":[\"charlie\"]}}", output.toString());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.