in src/Microsoft.Azure.WebJobs.Extensions.Dapr/Triggers/DaprTopicTriggerBindingProvider.cs [100:119]
protected override object ConvertFromJson(JsonElement jsonElement, Type destinationType)
{
// The input is always expected to be an object in the Cloud Events schema
// https://github.com/cloudevents/spec/blob/v1.0/spec.md#example
if (jsonElement.ValueKind == JsonValueKind.Object)
{
if (destinationType == typeof(CloudEvent))
{
return CloudEventFormatter.ConvertFromJsonElement(jsonElement, null);
}
else if (jsonElement.TryGetProperty("data", out JsonElement eventData))
{
// Do the generic conversion from the "data" payload
return JsonSerializer.Deserialize(eventData.GetRawText(), destinationType)
?? throw new InvalidOperationException("Failed to deserialize event data");
}
}
return base.ConvertFromJson(jsonElement, destinationType);
}