How to Debug System.Text.Json Deserializer

Viewed 1615

In the case of deserializing JSON data using System.Text.Json where the data doesn't match the target model, it throws a NotSupportedException with no detail whatsoever.

If the data is complex, it can be very difficult to pin-point where the problem occurred.

Is there a way to get some more debug information, or some hint as to which member failed to deserialize?

EDIT

Here's a sample command

var result = await JsonSerializer.DeserializeAsync<ApiResponse<T>>(responseStream, OntraportSerializerOptions.Default, CancellationToken.None).ConfigureAwait(false);

Error message:

The collection type 'System.Collections.Generic.Dictionary2[System.Int32,OntraportApi.Models.ResponseSectionFields]' on 'OntraportApi.Models.ApiResponse1[System.Collections.Generic.Dictionary`2[System.Int32,OntraportApi.Models.ResponseSectionFields]].Data' is not supported.'

responseStream.Length = 18494, want me to paste it?

0 Answers
Related