I’ve searched "all over" the internet and can’t find a solution to my problem.
I want to deserialize the following string
{"retention": [
{ "kinds": [0, 1, [5, 7], [40, 49]], "time": 3600, "count": 10000 }
]}kinds[0] -> integer
kinds[1] -> integer
kinds[2] -> integer range
public class RelayRetention
{
public override string ToString()
{
string text = Environment.NewLine;
return text;
}
//[JsonPropertyName("kinds")] public int[][]? KindsArrys { get; set; }
[JsonPropertyName("kinds")] public int[]? Kinds { get; set; }
[JsonPropertyName("time")] public int? Time { get; set; }
[JsonPropertyName("count")] public int? Count { get; set; }
}
string s = "{"retention": [
{ "kinds": [0, 1, [5, 7], [40, 49]], "time": 3600, "count": 10000 }";
]}
RelayRetention r = JsonSerializer.Deserialize<RelayRetention>(s);
2
Answers
you have to fix your code and class