GenerateContentResponseExtensionsToObjectsT Method

Converts JSON blocks contained within the GenerateContentResponse into objects of the specified type.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public static List<T> ToObjects<T>(
	this GenerateContentResponse response
)
where T : class

Parameters

response  GenerateContentResponse
The GenerateContentResponse containing JSON blocks to convert.

Type Parameters

T
The type to which the JSON blocks are converted.

Return Value

ListT
A list of objects of type T. Returns an empty list if no JSON blocks are found or successfully converted.

Usage Note

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