bson/src/main/org/bson/BsonDocument.java
public String toJson(final JsonWriterSettings settings) {
        StringWriter writer = new StringWriter();
        new BsonDocumentCodec().encode(new JsonWriter(writer, settings), this, EncoderContext.builder().build());
        return writer.toString();
    }
public String toJson(final JsonWriterSettings settings) {
        StringWriter writer = new StringWriter();
        new BsonDocumentCodec().encode(new JsonWriter(writer, settings), this, EncoderContext.builder().build());
        return writer.toString();
    }
Gets a JSON representation of this document using the given {@code JsonWriterSettings}.
@param settings the JSON writer settings
@return a JSON representation of this document