Reputation: 105
I have a json string that i am trying to deserialize into an object list using Newton. But it gives the
error Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List
The format of the json string is.
[ { "key": "1", "value": "Package1" }, { "key": "some name", "value": "Package2" } ]
the Model is defined as
public class RootObject
{
public string key { get; set; }
public string value { get; set; }
}
And i'm using the following method to deserialize it, where json is the string listed above.
var resultList = JsonConvert.DeserializeObject<List<RootObject>>(json);
I'm not sure where i'm going wrong here, any help would be appreciated.
Upvotes: 0
Views: 515