c# - 如何调试 System.Text.Json 反序列化器
问题描述
在使用 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.ApiResponse
1[System.Collections.Generic.Dictionary`2[System.Int32,OntraportApi.Models.ResponseSectionFields]].Data”。
responseStream.Length = 18494,要我粘贴吗?
解决方案
推荐阅读
- python-3.x - Pandas 在对象列上变换
- python - 如何在python中运行服务器
- sybase - 用于匹配字符串之间的模式的 Sybase like 子句
- rust - 有没有办法在 fsanitize 中断/崩溃时捕获子进程标准输出?
- c++ - 如何将 ON_CALL 的默认返回值设置为 gmock 的 const 方法?
- php - laravel echo 是否支持媒体流数据
- swift - 在命令行应用程序中使用 Swift 中的 URLSession POST 请求
- react-native - 是否有任何库可以将录制的视频转换为反应原生的特定宽高比(裁剪)?
- android - 带有深度链接的导航文件之间的非法循环引用导航组件
- bazel - Python 测试无法打印对本地包的依赖项