.net - Deserialize json object list with newton in c# -


i have json string trying deserialize object list using newton. gives

error cannot deserialize current json object (e.g. {"name":"value"}) type 'system.collections.generic.list

the format of json string is.

 [ { "key": "1", "value": "package1" }, { "key": "some name", "value": "package2" } ] 

the model defined

public class rootobject {     public string key { get; set; }     public string value { get; set; } } 

and i'm using following method deserialize it, json string listed above.

var resultlist = jsonconvert.deserializeobject<list<rootobject>>(json); 

i'm not sure i'm going wrong here, appreciated.

try giving idictionary instead of list.


Comments