how to deserialize complex json to hashtable+array style

632 views c#

here is my code:

        string json = "{'047084de7e289476991970194dd14513':{'reload':[]}}";
        var r = JsonConvert.DeserializeObject(json);

in my json, hashtable include inner hashtable, the r["047084de7e289476991970194dd14513"] result is jobject, but I hope its a hashtable, how should I do?

I hope find a way like javascript JSON.parse to get a object that all inner key and value can accessable

I use mono in linux, so I cannot use JavaScriptSerializer

answered question

1 Answer


I find JsonConvert.DeserializeObject return JObject or JArray are like Hashtable and Array, so if parse result is jobject, I can cast result to JObject

        string json = "{'047084de7e289476991970194dd14513':{'reload':[]}}";
        var r = (JObject) JsonConvert.DeserializeObject(json);

posted this

Have an answer?


Please login first before posting an answer.