How to deserialize JSON into string Dictionary in ASP.NET/C# Core 1 (vNext)

Now that I’ve been coding in C# Core for a few weeks, I am discovering certain limitations and issues, like all engineers do, thus having to come up with my own solutions. Recently a friend told me he had issues deserializing JSON into string dictionary, which I’ve also had and solved recently.

Here I’d like to share a solution for deserializing JSON strings into single level Dictionary<string, string> and more complex 2-level Dictionary<string, Dictionary<string, string>>.

In the past with .NET 4.0, we were able to do this using System.Web.Script.Serialization.JavaScriptSerializer(), however, that method is not available in C# Core. We now have Newtonsoft.Json available for serialization, but for some reason it doesn’t handle deserializing into string Dictionaries.

Here is my solution: