I was playing with qBittorrent and thought it would be a cool little project to do something with in C#, while implementing a client for the api I was stumped when I came to this property in the json…
It’s part of the preferences api – https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-preferences

How can I represent that in C#?
At first I figured it’s just a dictionary, but its not a json array type so it breaks if I try to deserialize to a list or dictionary. If I set it as an object or dynamic it will deserialize ok but then how do I work with it? How would I change the value of an entry or add a new entry?
I’m sure there’s probably a simple solution.
It’s a Dictionary<string, int>. This is a good point to remember that a JavaScript object is basically a hashmap.
Ok, that’s weird. I swear when I tried Dictionary<string, int> before it threw an exception complaining about it not being a json array, but it seems to be working now.

I’ll put it down to late night coding :-/
Thanks.
C# devs
null reference exceptions

source