I am working with an Azure Durable Function and I am having some trouble with System.Text.Json In a real scenario I will have a Activity Function which will call an API Endpoint and will get some Json result, which will have an Array with multiple types(string and int).
I will try to describe the problem. Do you know a way to fix it?
So I am using this class to deserialize it to a C# Object.
public class JsonTest
{
public dynamic[] Test { get; set; }
}
And this is the sample Activity Function which does the deserialize.
[FunctionName("GetJson")]
public static JsonTest GetJson([ActivityTrigger] string id)
{
var jsonString = "{ \"Test\": [\"Fabrizio\", 39] }";
var result = JsonSerializer.Deserialize<JsonTest>(jsonString);
return result;
}
I can see that it works.
However once I return the Object from the Activity Function to the Orchestrator something goes wrong. I don't have the values anymore. Even if I try to expand it. I will eventually get an error. It also use Newtonsoft.Json.Linq.JToken but I don't know how related it is since I am just using System.text.json
First = '(new System.Linq.SystemCore_EnumerableDebugView<System.Collections.Generic.KeyValuePair<string, Newtonsoft.Json.Linq.JToken>>(foo.Test[0]).Items[0]).Value.First' threw an exception of type 'System.InvalidOperationException'