Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何调试System.Text.Json反序列化程序_C#_.net_.net Core_System.text.json - Fatal编程技术网

C# 如何调试System.Text.Json反序列化程序

C# 如何调试System.Text.Json反序列化程序,c#,.net,.net-core,system.text.json,C#,.net,.net Core,System.text.json,在使用System.Text.JSON反序列化JSON数据的情况下,如果数据与目标模型不匹配,它会抛出一个不带任何细节的NotSupportedException 如果数据复杂,则很难确定问题发生的位置 有没有办法获得更多的调试信息,或者关于哪个成员未能反序列化的提示 编辑 下面是一个示例命令 var result = await JsonSerializer.DeserializeAsync<ApiResponse<T>>(responseStream, Ontrapo

在使用System.Text.JSON反序列化JSON数据的情况下,如果数据与目标模型不匹配,它会抛出一个不带任何细节的NotSupportedException

如果数据复杂,则很难确定问题发生的位置

有没有办法获得更多的调试信息,或者关于哪个成员未能反序列化的提示

编辑

下面是一个示例命令

var result = await JsonSerializer.DeserializeAsync<ApiResponse<T>>(responseStream, OntraportSerializerOptions.Default, CancellationToken.None).ConfigureAwait(false);
var result=await JsonSerializer.DeserializeAsync(responseStream,OntraportSerializerOptions.Default,CancellationToken.None)。ConfigureAwait(false);
错误消息:

“OntraportApi.Models.ApiResponse”上的集合类型“System.Collections.Generic.Dictionary
2[System.Int32,OntraportApi.Models.ResponseSectionFields]”不支持“数据”


responseStream.Length=18494,要我粘贴吗?

查看堆栈跟踪?请向我们展示您的代码。您能给出一个问题示例吗?当我用错误反序列化JSON时,比如说当需要整数时出现字符串,我会得到一个非常有用的描述性错误:
System.Text.JSON.JsonException:JSON值无法转换为System.Int32。路径:$.widget.window.width |行号:5 | BytePositionLine:22。System.InvalidOperationException:无法将令牌类型“String”的值作为数字获取。
JSON流中错误的确切位置以及错误的JSONPath路径已存在。Demo fiddle here:我添加了一个示例命令和错误这里的问题是
System.Text.Json
只支持带有字符串键的字典,请参阅和。查看堆栈跟踪?请向我们展示您的代码。您能给出一个问题示例吗?当我用错误反序列化JSON时,比如说当需要整数时出现字符串,我会得到一个非常有用的描述性错误:
System.Text.JSON.JsonException:JSON值无法转换为System.Int32。路径:$.widget.window.width |行号:5 | BytePositionLine:22。System.InvalidOperationException:无法将令牌类型“String”的值作为数字获取。
JSON流中错误的确切位置以及错误的JSONPath路径已存在。Demo fiddle here:我添加了一个示例命令和错误这里的问题是
System.Text.Json
只支持带有字符串键的字典,请参阅和。