Converts an object to a JSON string.

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

Syntax

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

Parameters

obj
Type: T
The object.

Type Parameters

T
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 or .

See Also