@Override
 public void writeStartDocument(String encoding, String version) throws XMLStreamException {
   super.writeStartDocument(encoding, version);
   try {
     target.startObject();
   } catch (IOException e) {
     throw new XMLStreamException("Cannot start document", e);
   }
   getScope().getInfo().startObjectWritten = true;
 }
 @Override
 public void close() throws XMLStreamException {
   super.close();
   try {
     if (documentArray) {
       target.endArray();
     }
     target.close();
   } catch (IOException e) {
     throw new XMLStreamException("Close failed", e);
   }
 }
 @Override
 public void writeEndDocument() throws XMLStreamException {
   super.writeEndDocument();
   try {
     if (getScope().getInfo().isArray()) {
       target.endArray();
     }
     target.endObject();
   } catch (IOException e) {
     throw new XMLStreamException("Cannot end document", e);
   }
   getScope().getInfo().startObjectWritten = false;
 }
 /**
  * Write boolean value.
  *
  * @param value
  * @throws XMLStreamException
  */
 public void writeBoolean(Boolean value) throws XMLStreamException {
   if (getScope().getInfo().hasData()) {
     throw new XMLStreamException("Cannot write boolean value");
   }
   super.writeCharacters(value, XMLStreamConstants.CHARACTERS);
 }