I'm trying to deserialize a json string of form [{"key" : "Microsoft", "value":[{"Key":"Publisher","Value":"abc"},{"Key":"UninstallString","Value":"c:\temp"}]} and so on ] to a C# object.
It is basically in the form Dicionary<string, Dictionary<string, string>>. I tried using the Newtonsoft's JsonConvert.Deserialize but got an error:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.Dictionary`2[System.String,System.String]]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
Is there any other alternative way to do it?
var obj = JsonConvert.DeserializeObject(...). It works for your json stringim doing this currently.Why don't you try the code i posted? I tested it and it works.