Package de.odysseus.staxon.json

Examples of de.odysseus.staxon.json.JsonXMLStreamWriter$ScopeInfo


  private RemoveRootTarget createTarget(StringWriter result, QName root) throws IOException {
    return new RemoveRootTarget(new JsonStreamFactoryImpl().createJsonStreamTarget(result, false), root, ':');
  }

  private JsonXMLStreamWriter createXmlStreamWriter(StringWriter result, QName root) throws IOException {
    return new JsonXMLStreamWriter(createTarget(result, root), false, true, ':', true);
  }
View Full Code Here


   * <code>&lt;alice&gt;&lt;bob&gt;charlie&lt;/bob&gt;&lt;bob&gt;david&lt;/bob&gt;&lt;/alice&gt;</code>
   */
  @Test
  public void testArray() throws Exception {
    StringWriter result = new StringWriter();
    JsonXMLStreamWriter writer = createXmlStreamWriter(result, new QName("alice"));
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeStartArray("bob");
    writer.writeStartElement("bob");
    writer.writeCharacters("charlie");
    writer.writeEndElement();
    writer.writeStartElement("bob");
    writer.writeCharacters("david");
    writer.writeEndElement();
    writer.writeEndArray();
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("{\"bob\":[\"charlie\",\"david\"]}", result.toString());
  }
View Full Code Here

  private AutoArrayTarget createTarget(StringWriter result) throws IOException {
    return new AutoArrayTarget(new JsonStreamFactoryImpl().createJsonStreamTarget(result, false));
  }
 
  private JsonXMLStreamWriter createXmlStreamWriter(StringWriter result) throws IOException {
    return new JsonXMLStreamWriter(createTarget(result), false, true, ':', true);
  }
View Full Code Here

  }

  @Test
  public void testArray3() throws Exception {
    StringWriter result = new StringWriter();
    JsonXMLStreamWriter writer = createXmlStreamWriter(result);
    writer.writeStartDocument();
    writer.writeStartElement("alice");
    writer.writeStartArray("bob");
    writer.writeStartElement("bob");
    writer.writeCharacters("charlie");
    writer.writeEndElement();
    writer.writeEndArray();
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.close();
    Assert.assertEquals("{\"alice\":{\"bob\":[\"charlie\"]}}", result.toString());
  }
View Full Code Here

  private AutoPrimitiveTarget createTarget(StringWriter result) throws IOException {
    return new AutoPrimitiveTarget(new JsonStreamFactoryImpl().createJsonStreamTarget(result, false), false);
  }
 
  private JsonXMLStreamWriter createXmlStreamWriter(StringWriter result) throws IOException {
    return new JsonXMLStreamWriter(createTarget(result), false, true, ':', true);
  }
View Full Code Here

TOP

Related Classes of de.odysseus.staxon.json.JsonXMLStreamWriter$ScopeInfo

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.