Quantcast
Channel: How can I deserialize JSON to a simple Dictionary in ASP.NET? - Stack Overflow
Viewing all articles
Browse latest Browse all 23

Answer by haldo for How can I deserialize JSON to a simple Dictionary in ASP.NET?

$
0
0

System.Text.Json

This can now be done using System.Text.Json which is built-in to .NET Core 3.0. It's now possible to deserialize JSON without using third-party libraries.

var json = @"{""key1"":""value1"",""key2"":""value2""}";var values = JsonSerializer.Deserialize<Dictionary<string, string>>(json);

Also available in NuGet package System.Text.Json if using .NET Standard or .NET Framework.


Make sure to read and understand:


Viewing all articles
Browse latest Browse all 23


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>