feat: Map JSON DataContent to Part.Data - #448
Conversation
Map JSON DataContent payloads to structured Part.Data values while preserving their media type. Continue using Part.Raw for non-JSON data and surface malformed content declared as JSON. Fixes a2aproject#447 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea72bc53-dec7-452c-94f6-6a0a50e56b66
|
Verified this independently against current One observation on the "symmetric round-tripping" motivation from #447. The symmetry currently holds only for exactly Media type parameters and casing are lost the same way ( A small change on the reverse branch closes the loop for the content = new DataContent(
JsonSerializer.SerializeToUtf8Bytes(data, A2AJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement))),
IsJsonMediaType(part.MediaType) ? part.MediaType! : "application/json");Guarding on |
Preserve valid JSON media types when converting structured Part.Data values back to DataContent, while falling back to application/json for missing or non-JSON media types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea72bc53-dec7-452c-94f6-6a0a50e56b66
…yMenshykh/a2a-dotnet into fix/json-data-content-part
Thanks for catching this. It makes sense, and I’ve added the suggested change and tests. |
Summary
DataContentpayloads to structuredPart.Datavaluesapplication/json, media type parameters, and+jsonsuffixesDataContentmapped toPart.RawTests
dotnet test tests\A2A.UnitTests\A2A.UnitTests.csproj --no-restore --filter "FullyQualifiedName~AIContentExtensionsTests" --verbosity quietFixes #447