ContentExtensionsToObjectT Method

Converts the JSON content of a Content object into an instance of the specified type.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public static T ToObject<T>(
	this Content content
)
where T : class

Parameters

content  Content
The Content object containing JSON data to be converted.

Type Parameters

T
The target type to which the JSON content will be deserialized. Must be a class.

Return Value

T
An instance of type T if conversion succeeds, or null if no valid JSON data is found or deserialization fails.

Usage Note

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