Language

CoreActivity.ToJson Method

Definition

Overloads

Name Description
ToJson()

Serializes the current activity to a JSON string.

ToJson<T>(JsonTypeInfo<T>)

Serializes the current activity to a JSON string using the specified JsonTypeInfo<T> for source-generated serialization.

ToJson<T>(T)

Serializes the specified activity instance to a JSON string using reflection-based serialization.

ToJson()

Serializes the current activity to a JSON string.

public virtual string ToJson();
abstract member ToJson : unit -> string
override this.ToJson : unit -> string
Public Overridable Function ToJson () As String

Returns

A JSON string representation of the activity.

Applies to

ToJson<T>(JsonTypeInfo<T>)

Serializes the current activity to a JSON string using the specified JsonTypeInfo<T> for source-generated serialization.

public string ToJson<T>(System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> jsonTypeInfo) where T : Microsoft.Teams.Core.Schema.CoreActivity;
member this.ToJson : System.Text.Json.Serialization.Metadata.JsonTypeInfo<'T (requires 'T :> Microsoft.Teams.Core.Schema.CoreActivity)> -> string (requires 'T :> Microsoft.Teams.Core.Schema.CoreActivity)
Public Function ToJson(Of T As CoreActivity) (jsonTypeInfo As JsonTypeInfo(Of T)) As String

Type Parameters

T

The type of the activity to serialize. Must inherit from CoreActivity.

Parameters

jsonTypeInfo
JsonTypeInfo<T>

The JSON type info that provides serialization metadata for type T.

Returns

A JSON string representation of the activity.

Applies to

ToJson<T>(T)

Serializes the specified activity instance to a JSON string using reflection-based serialization.

public static string ToJson<T>(T instance) where T : Microsoft.Teams.Core.Schema.CoreActivity;
static member ToJson : 'T -> string (requires 'T :> Microsoft.Teams.Core.Schema.CoreActivity)
Public Shared Function ToJson(Of T As CoreActivity) (instance As T) As String

Type Parameters

T

The type of the activity to serialize. Must inherit from CoreActivity.

Parameters

instance
T

The activity instance to serialize. Cannot be null.

Returns

A JSON string representation of the specified activity instance.

Remarks

Uses reflection-based serialization to support custom activity types that extend CoreActivity. The resulting JSON reflects the public properties of the activity instance.

Applies to