}
public void testNestedArrayOfChildren() throws Exception {
StringWriter strWriter = new StringWriter();
MappedNamespaceConvention con = new MappedNamespaceConvention();
AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
w.writeStartDocument();
w.writeStartElement("root");
w.writeStartElement("subchild1");
w.writeStartElement("subchild2");
w.writeCharacters("first sub2");
w.writeEndElement();
w.writeStartElement("subchild2");
w.writeStartElement("subchild3");
w.writeCharacters("first sub3");
w.writeEndElement();
w.writeStartElement("subchild3");
w.writeCharacters("second sub3");
w.writeEndElement();
w.writeEndElement();
w.writeStartElement("subchild2");
w.writeCharacters("third sub2");
w.writeEndElement();
w.writeEndElement();
w.writeStartElement("subchild1");
w.writeCharacters("sub1");
w.writeEndElement();
//w.writeEndElement();
w.writeEndElement();
w.writeEndDocument();
w.close();
strWriter.close();
assertEquals("{\"root\":{\"subchild1\":[{\"subchild2\":[\"first sub2\",{\"subchild3\":[\"first sub3\",\"second sub3\"]},\"third sub2\"]},\"sub1\"]}}"
, strWriter.toString());
}