my json is like
{
"code":"1",
"message":"The request succeeded",
"contacts":
{ "contactId":"58330efb45cedb9087e281e6",
"email":"",
"firstName":"",
"lastName":"",
"number":"4145075733"
}
}
and i am trying to use DeserializeObject with this Generic.List
public class AllContacts
{
public string code { get; set; }
public string message { get; set; }
public List<ContactList> contacts { get; set; }
}
public class ContactList
{
public string contactId { get; set; }
public string email { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string number { get; set; }
}
this is working fine with two or more data in contact array but it's not working in single data.
Error:
Cannot deserialize the current JSON object (eg.{"name":"value"}) into type 'System.Collections.Generic.List'1[smsApplication.Controllers.ContactList]' because the type requires a JSON array to deserialize correctly. To fix this error either change the JSON to a JSON array or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or
List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.