public static byte[] toByteArray(Document document, boolean tensorShortForm, boolean tensorDirectValues) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        JsonWriter writer = new JsonWriter(out, tensorShortForm, tensorDirectValues);
        writer.write(document);
        return out.toByteArray();
    }
Utility method to easily serialize a single document.
TODO: remove

@param document the document to be serialized
@param tensorShortForm whether tensors should be serialized in a type-dependent short form
@param tensorDirectValues whether tensors should be serialized as direct values or wrapped in a
                          map also containing the type
@return the input document serialised as UTF-8 encoded JSON
document/src/main/java/com/yahoo/document/json/JsonWriter.java