I have to assign json array of string to a c# class. I have done like below. But I got an exceptio
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'LoggedInUserDetails' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo 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.\r\nPath '', line 1, position 1."}
public class LoggedInUserDetails
{
public string login_user_name
{
get; set;
}
public string login_user_id
{
get; set;
}
}
var GetResponse = await response2.Content.ReadAsStringAsync();
//"[{\"login_user_name\":\"Rahul\",\"login_user_id\":\"43\"}]"
LoggedInUserDetails obj = JsonConvert.DeserializeObject<LoggedInUserDetails>(GetResponse);
Variables.login_user_name = obj.login_user_name;
Variables.login_user_id= obj.login_user_id;