Method ToJson
ToJson<TNominalType>(TNominalType, JsonWriterSettings, IBsonSerializer<TNominalType>, Action<Builder>, BsonSerializationArgs)
Serializes an object to a JSON string.
public static string ToJson<TNominalType>(this TNominalType obj, JsonWriterSettings writerSettings = null, IBsonSerializer<TNominalType> serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)
Parameters
obj
TNominalTypeThe object.
writerSettings
JsonWriterSettingsThe JsonWriter settings.
serializer
IBsonSerializer<TNominalType>The serializer.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
Returns
- string
A JSON string.
Type Parameters
TNominalType
The nominal type of the object.
ToJson(object, Type, JsonWriterSettings, IBsonSerializer, Action<Builder>, BsonSerializationArgs)
Serializes an object to a JSON string.
public static string ToJson(this object obj, Type nominalType, JsonWriterSettings writerSettings = null, IBsonSerializer serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)
Parameters
obj
objectThe object.
nominalType
TypeThe nominal type of the objectt.
writerSettings
JsonWriterSettingsThe JsonWriter settings.
serializer
IBsonSerializerThe serializer.
configurator
Action<BsonSerializationContext.Builder>The serialization context configurator.
args
BsonSerializationArgsThe serialization args.
Returns
- string
A JSON string.
Exceptions
- ArgumentNullException
nominalType
- ArgumentException
serializer