Skip to main content

65 posts tagged with "JSON"

JSON Data Format, Parsing, and Serialization

View All Tags

Fixed: The Adaptive Cards Designer saves the card as version 1.6

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

I designed an Adaptive Card for Microsoft Teams in the Adaptive Cards Designer, and every copy of it came out as version 1.6, one above the highest version Teams supports. The Designer has no setting for the version, and when I changed it in its payload editor, the copy and the export still said 1.6. The fix is to set the version in your own copy of the card.

Fixed: Cannot get the value of a token type 'String' as a boolean when reading Adaptive Card values in C#

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

My Microsoft 365 Agents SDK agent answered an Adaptive Card's Book desk button with The JSON value could not be converted to DeskBooking.DeskRequest. Path: $.monitor, followed by Cannot get the value of a token type 'String' as a boolean. The card's check box had sent the text "true", not the value true, and the JSON reader won't turn text into a bool. The fix is to read every value a card sends as the string it is.

How to Log the JSON of an Incoming Activity in the Microsoft 365 Agents SDK in C#

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

When an agent misbehaves, the first question is what actually arrived. In the Microsoft 365 Agents SDK, one call answers it: ToJson() turns the incoming activity into JSON, and your logger writes it out. That's the only way to see the raw activity once your agent runs in Teams or Microsoft 365 Copilot, where no test tool shows it to you.

How to Send a Custom Activity from the Microsoft 365 Agents Playground

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Some activities never come from typing: a web page telling your agent the user switched to dark mode, a thumbs-up on a reply. The Microsoft 365 Agents Playground can send them anyway. Its Custom activity option lets you write any activity as JSON and deliver it to your agent, so you can test the code that handles it on your own machine.

How to Use an Enum Parameter in a Microsoft Agent Framework Function Tool in C#

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

Some tool parameters can only take a few values: a size, a priority, a status. Make such a parameter a C# enum, and Microsoft Agent Framework tells the model exactly which values exist, so it picks one of them instead of making one up. One thing still gets through: a number that isn't one of the values. This guide shows both with a small coffee-ordering agent and a real model, and adds the one-line check that closes the gap.

Fixed: JsonTypeInfo metadata for type was not provided by TypeInfoResolver of type 'Microsoft.Extensions.AI.AIJsonUtilities+JsonContext'

· 11 min read
Jagdish Kumawat
Founder @ Dewiride

In a .NET 10 file-based app, turning a method into a Microsoft Agent Framework tool with AIFunctionFactory.Create crashed with System.NotSupportedException: JsonTypeInfo metadata for type ... was not provided by TypeInfoResolver of type 'Microsoft.Extensions.AI.AIJsonUtilities+JsonContext'. File-based apps target Native AOT by default, and that turns off reflection-based JSON. One #:property PublishAot=false line fixed it; a source-generated JSON context fixes it while keeping Native AOT.

How to Validate a JSON Request Body in a Next.js Route Handler with Zod

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A route handler receives whatever a client sends: missing fields, wrong types, text that isn't JSON at all. A zod schema describes the body you accept and checks it in one call, so the rest of the handler works with data that is complete and typed. This guide builds a small POST endpoint and shows real answers for valid, invalid, malformed and padded bodies.