public String toJson() {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        JsonWriter writer = new JsonWriter(buffer);
        writer.write(this);
        return buffer.toString(StandardCharsets.UTF_8);
    }
Get JSON representation of the document root and its children contained in a JSON object

@return JSON representation of document
document/src/main/java/com/yahoo/document/Document.java