Quantcast
Browsing latest articles
Browse All 23 View Live

Answer by Adel Tabareh for How can I deserialize JSON to a simple Dictionary...

Here is my solution with System.Text.Json. You get a json string for the nested objects which in own turn can be converted to needed type later on.public static Dictionary<string,string>...

View Article


Answer by wdanxna for How can I deserialize JSON to a simple Dictionary in...

For anyone who is trying to convert JSON to dictionary just for retrieving some value out of it. There is a simple way using Newtonsoft.JSONusing Newtonsoft.Json.Linq...JObject o =...

View Article


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

System.Text.JsonThis 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 =...

View Article

Answer by FistOfFury for How can I deserialize JSON to a simple Dictionary in...

Based on comments above try JsonConvert.DeserializeObject<Dictionary<string,dynamic>>(json)var json = @"{""key1"":1,""key2"":""value2"",...

View Article

Answer by Kjeld Poulsen for How can I deserialize JSON to a simple Dictionary...

A bit late to the game, but non of the above solutions pointed me in the direction of a pure and simple .NET, no json.net solution. So here it is, ended up being very simple. Below a full running...

View Article


Answer by Gering for How can I deserialize JSON to a simple Dictionary in...

You could use Tiny-JSONstring json = "{\"key1\":\"value1\", \"key2\":\"value2\"}";IDictionary<string, string> dict = Tiny.Json.Decode<Dictionary<string, string>>(json);

View Article

Answer by Falko for How can I deserialize JSON to a simple Dictionary in...

I just needed to parse a nested dictionary, like{"x": {"a": 1,"b": 2,"c": 3 }}where JsonConvert.DeserializeObject doesn't help. I found the following approach:var dict =...

View Article

Answer by Nyerguds for How can I deserialize JSON to a simple Dictionary in...

It seems all of these answers here just assume you can get that little string out of a bigger object... for people looking to simply deserealize a large object with such a dictionary somewhere inside...

View Article


Answer by Bryan for How can I deserialize JSON to a simple Dictionary in...

Mark Rendle posted this as a comment, I wanted to post it as an answer since it's the only solution that has worked so far to return the success and the error-codes json results from the Google...

View Article


Answer by Jordan for How can I deserialize JSON to a simple Dictionary in...

I've added upon the code submitted by jSnake04 and Dasun herein. I've added code to create lists of objects from JArray instances. It has two-way recursion but as it is functioning on a fixed, finite...

View Article

Answer by Rafał Kłys for How can I deserialize JSON to a simple Dictionary in...

My approach directly deserializes to IDictionary, without JObject or ExpandObject in between. The code uses converter, which is basically copied from ExpandoObjectConverter class found in JSON.NET...

View Article

Answer by jSnake04 for How can I deserialize JSON to a simple Dictionary in...

I added a check for null values in the JSON to the other answer I had same problem so I wrote this my self. This solution isdifferentiated from other answers because it can deserialize in tomultiple...

View Article

Answer by Dan Csharpster for How can I deserialize JSON to a simple...

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;...

View Article


Answer by northben for How can I deserialize JSON to a simple Dictionary in...

I just implemented this in RestSharp. This post was helpful to me.Besides the code in the link, here is my code. I now get a Dictionary of results when I do something like this:var jsonClient = new...

View Article

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

If you're after a lightweight, no-added-references kind of approach, maybe this bit of code I just wrote will work (I can't 100% guarantee robustness though).using System;using...

View Article


Answer by jeremysawesome for How can I deserialize JSON to a simple...

Annoyingly enough, if you want to use the default model binders, it looks like you will have to use numerical index values like a form POST.See the following excerpt from this article...

View Article

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

Tried to not use any external JSON implementation so i deserialised like this:string json = "{\"id\":\"13\", \"value\": true}";var serializer = new JavaScriptSerializer(); //using...

View Article


Answer by Dasun for How can I deserialize JSON to a simple Dictionary in...

I had the same problem, so I wrote this my self. This solution is differentiated from other answers because it can deserialize in to multiple levels. Just send JSON string in to deserializeToDictionary...

View Article

Answer by JP Richardson for How can I deserialize JSON to a simple Dictionary...

For those searching the internet and stumbling upon this post, I wrote a blog post on how to use the JavaScriptSerializer class.Read...

View Article

Answer by Crispy for How can I deserialize JSON to a simple Dictionary in...

I did discover .NET has a built in way to cast the JSON string into a Dictionary<String, Object> via the System.Web.Script.Serialization.JavaScriptSerializer type in the 3.5 System.Web.Extensions...

View Article

Answer by James Newton-King for How can I deserialize JSON to a simple...

Json.NET does this...string json = @"{""key1"":""value1"",""key2"":""value2""}";var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);More examples: Serializing...

View Article


Answer by richardtallent for How can I deserialize JSON to a simple...

Edit: This works, but the accepted answer using Json.NET is much more straightforward. Leaving this one in case someone needs BCL-only code.It’s not supported by the .NET framework out of the box. A...

View Article


How can I deserialize JSON to a simple Dictionary in ASP.NET?

I have a simple key/value list in JSON being sent back to ASP.NET via POST. Example:{ "key1": "value1", "key2": "value2"}I AM NOT TRYING TO DESERIALIZE INTO STRONGLY-TYPED .NET OBJECTSI simply need a...

View Article
Browsing latest articles
Browse All 23 View Live