C
C#12mo ago
Zigy

Problem with deserializing JSON file.

Hello there I am trying to deserialize a JSON like the following: {"[982367487645900, 504339357638715104]":["id"]} Into an Dictionary<List<long>, List<string>> But newtonsoft.json (Which is what I am using for deserializing the JSON file) says that it cannot convert a string into a collection
The string here being "[76561198801345900, 504332241820975104]"
3 Replies
Jimmacle
Jimmacle12mo ago
because that key is a string, not an array pretty sure you can't use an array as a key in json
Zigy
ZigyOP12mo ago
Ah thank you
gerard
gerard12mo ago
If you really, really want Dictionary<List<long>, List<string>>, you can make a JsonConverter for it: https://paste.mod.gg/xpdtuesgzdjf/0 Also note that the array is in a string, so it's a string. It's hard to see without syntax highlighting:
{"[982367487645900, 504339357638715104]":["id"]}
{"[982367487645900, 504339357638715104]":["id"]}

Did you find this page helpful?