Quantcast
Viewing latest article 13
Browse Latest Browse All 23

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

I would suggest using System.Runtime.Serialization.Json that is part of .NET 4.5.

[DataContract]public class Foo{   [DataMember(Name = "data")]   public Dictionary<string,string> Data { get; set; }}

Then use it like this:

var serializer = new DataContractJsonSerializer(typeof(List<Foo>));var jsonParams = @"{""data"": [{""Key"":""foo"",""Value"":""bar""}] }";var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonParams));var obj = serializer.ReadObject(stream);Console.WriteLine(obj);

Viewing latest article 13
Browse Latest Browse All 23

Trending Articles



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