C#C
C#3y ago
moul7anout

Text.Json Error

Mates I am going fucking insane. I've been working on this for a while and it's just killing me.

"[{\"Id\":732870,\"UserId\":\"76561198432850031@steam\",\"LastSeen\":\"2022-12-27T00:31:32.738454\",\"FirstSeen\":\"2022-12-26T22:31:43.768427\",\"Activity\":{\"2022-12-26T00:00:00Z\":3209.0,\"2022-12-27T00:00:00Z\":1894.0},\"DoNotTrack\":false,\"Staff\":true,\"Kills\":0,\"Deaths\":0,\"ExperiencePoints\":0,\"ColaDrink\":1,\"Medkits\":0,\"AdrenalineShots\":0,\"Survival\":0,\"PocketEscapes\":0,\"RoundsPlayed\":6,\"Teamkills\":0,\"EscapeTimes\":[],\"Level\":0,\"Name\":null,\"IgnoreStats\":0}]"

I've got this json here.
It's giving me this exception: "System.Text.Json.JsonException: The JSON value could not be converted to StatsBot.JsonHelper+Player[]. Path: $ | LineNumber: 0 | BytePositionInLine: 495.

For some reason, when I use a different json (attached in image) it works.

The code I'm using is
System.Text.Json.JsonSerializer.Deserialize<Player[]>(response.Content, Options);

My options are just "PropertyNameCaseInsensitive" which is set to true.
image.png
Was this page helpful?