This System.ArrayTypeMismatchException is a known type of compatibility issue when using System.Text.Json with custom converters (like ObjectToInferredTypersConverter) on .NET framework 4.7x. This error is most Likely due to type inference and boxing/unboxing behaviour that System.Text.Json doesn't handle properly in legacy frameworks.
1. Use Newtonsoft.Json-
You’re already doing this and it’s the best approach if you’re targeting .Net framework 4.7
2. Avoid objects and use strong typing with System.Text.Json
If you must use System.Text.Json , avoid object deserialization with custom converters. Instead deserialize to a concrete type:
string json = ”true”;
bool result = JsonSerializer.Deserialize<bool>(json);
Assert.IsTrue(result);
This avoids the inference issue entirely.
3. Replace or Remove ObjectToInferredTypersConverter
If you wrote or used a third party ObjectToInferredTypersConverter, it’s likely doing dynamic type inspection or unsafe casting. It may work fine on .Net core/.Net 6+ but break on .Net framework.
You can either avoid using it entirely or rework it to avoid assumptions about object arrays and boxed values