driver-core/src/main/com/mongodb/BasicDBObject.java
public String toJson(final JsonWriterSettings writerSettings) {
        return toJson(writerSettings, DBObjectCodec.getDefaultRegistry().get(BasicDBObject.class));
    }
public String toJson(final JsonWriterSettings writerSettings) {
        return toJson(writerSettings, DBObjectCodec.getDefaultRegistry().get(BasicDBObject.class));
    }
Gets a JSON representation of this document

<p>With the default {@link DBObjectCodec}.</p>

@param writerSettings the json writer settings to use when encoding
@return a JSON representation of this document
@throws org.bson.codecs.configuration.CodecConfigurationException if the document contains types not in the default registry