Bot Builder v4 IgnoreEmptyItemsConverter causes an issue when ReadJson
See original GitHub issuePlatform
Bot Builder v4.0 (dotnet core)
Author or host
web api (Bot Framework)
Version of SDK
1.1
Issue
When deserialize the DialogState which contains the AdaptiveCard, it fails with error "Error reading JArray from JsonReader at
var array = JArray.Load(reader);.
Error: Current JsonReader item is not an array: StartObject. Path 'DialogState.DialogStack.$values[0].State.dialogs.DialogStack.$values[0].State.options.Prompt.attachments.$values[0].content.action"
This caused by [JsonConverter(typeof(IgnoreEmptyItemsConverter<AdaptiveAction>))] attribute on AdaptiveCard which will be called while deserialization but it’s not actually an array yet, as $value holds an array not action (nor body)
"actions": {
"$type": "System.Collections.Generic.List`1[[AdaptiveCards.ActionBase, AdaptiveCards]], System.Private.CoreLib",
"$values": [
{
"$type": "AdaptiveCards.SubmitAction, AdaptiveCards",
"type": "Action.Submit",
"data": "Test",
"title": "Test"
}
]
}
We should try/catch JArray.Load
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:18 (5 by maintainers)
Top Results From Across the Web
ChoiceSetConverter.ReadJson Method
Indicates if existingValue has a value. serializer: Newtonsoft.Json.JsonSerializer. The calling serializer. Returns. ChoiceSet. The interpreted ...
Read more >Bot Framework v4 SDK Templates for Visual Studio
Microsoft Bot Builder V4 Templates will help you build new conversational AI bots using the Microsoft Bot Framework v4. Templates. There are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you, this helps.
So it looks like the problem is the Adaptive Card object model isn’t fully compatible with NewtonSoft’s JSON serialization/deserialization algorithm when TypeNameHandling.All is used. Namely, an AdaptiveCard object cannot be round-tripped (FromObject then ToObject) in TypeNameHandling.All mode.
I’ll leave it to @khouzam and @paulcam206 from here (maybe they had already understood all this for that matter.)
@v-kydela now I see, that works, thank you!