在使用 System.Text.Json 反序列化 JSON 数据且数据与目标模型不匹配的情况下,它会抛出 NotSupportedException 且没有任何细节。
如果数据很复杂,则很难确定问题发生的位置。
有没有办法获得更多的调试信息,或者一些关于哪个成员未能反序列化的提示?
编辑
这是一个示例命令
var result = await JsonSerializer.DeserializeAsync<ApiResponse<T>>(responseStream, OntraportSerializerOptions.Default, CancellationToken.None).ConfigureAwait(false);
错误信息:
不支持集合类型“System.Collections.Generic.Dictionary
2[System.Int32,OntraportApi.Models.ResponseSectionFields]' on 'OntraportApi.Models.ApiResponse1[System.Collections.Generic.Dictionary`2[System.Int32,OntraportApi.Models.ResponseSectionFields]].Data”。
responseStream.Length = 18494,要我粘贴吗?