I am trying to extract from a response, but when trying to DeserializeObject I get the following error.
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'JSonClasses+Item' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.
My Response is:
[{"Odid":45606,"UserId":22728,"FirstName":"FirstName ","MiddleName":null,"LastName":"LastName","UserName":"FirstName.LastName","ExternalEmail":"[email protected]","DefinedId":"12345","UniqueIdentifier":"null","Activation":{"IsActive":true},"DisplayName":"FirstName LastName"}]
Here is how I am trying to DeserializeObject this response:
public class Activation
{
public bool IsActive { get; set; }
}
public class Item
{
public int OrgId { get; set; }
public int UserId { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string UserName { get; set; }
public string ExternalEmail { get; set; }
public string OrgDefinedId { get; set; }
public string UniqueIdentifier { get; set; }
public Activation Activation { get; set; }
public string DisplayName { get; set; }
}
var responceID= JsonConvert.DeserializeObject<JSonClasses.Item>(response.Content);
I also have tried to use the following method to convert it into a Dynamic object and then try to extract data into Item class but the same error occurs:
dynamic response2 = JsonConvert.DeserializeObject(response.Content);
What am I doing wrong?