BsonExtensionMethodsToJson Method (Object, Type)MongoDB C# Driver API Documentation
Converts an object to a JSON string.

Namespace: MongoDB.Bson
Assembly: MongoDB.Bson (in MongoDB.Bson.dll) Version: { version: '', semver: '1.11.0', commit: '791a16588d4a8b3b118a8b3b57cfa436fec5d3da', commitDate: '2015-12-08 22:55:45' }

public static string ToJson(
	this Object obj,
	Type nominalType


Type: SystemObject
The object.
Type: SystemType
The nominal type of the object.

Return Value

Type: String
A JSON string.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also