Table of Contents

Method ToJson

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

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 TNominalType

The object.

writerSettings JsonWriterSettings

The JsonWriter settings.

serializer IBsonSerializer<TNominalType>

The serializer.

configurator Action<BsonSerializationContext.Builder>

The serialization context configurator.

args BsonSerializationArgs

The 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 object

The object.

nominalType Type

The nominal type of the objectt.

writerSettings JsonWriterSettings

The JsonWriter settings.

serializer IBsonSerializer

The serializer.

configurator Action<BsonSerializationContext.Builder>

The serialization context configurator.

args BsonSerializationArgs

The serialization args.

Returns

string

A JSON string.

Exceptions

ArgumentNullException

nominalType

ArgumentException

serializer