Converts an object to a JSON string.

Namespace: MongoDB.Bson
Assembly: MongoDB.Bson (in MongoDB.Bson.dll)

Syntax

C#
public static string ToJson<TNominalType>(
	this TNominalType obj
)
Visual Basic
<ExtensionAttribute> _
Public Shared Function ToJson(Of TNominalType) ( _
	obj As TNominalType _
) As String
Visual C++
public:
[ExtensionAttribute]
generic<typename TNominalType>
static String^ ToJson(
	TNominalType obj
)

Parameters

obj
Type: TNominalType
The object.

Type Parameters

TNominalType
The nominal type of the object.

Return Value

A JSON string.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . 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).

Version Information

1.8.1.20

Supported in: 4.0, 3.5

See Also