Я использую IRestresponse для получения содержимого JSON с сервера.Это сложный json, и я хочу десериализовать его в список объектов, который имитирует json hirerachy (в основном класс DTO), и извлекать его, просматривая список.Я сделал это через RestAssured через Java ..... но не могу найти решение в C #
#the following code is in java. This class imitates the Json Object and follows it's hierarchy
public class MyPojo
{
private String code;
private String lastActive;
private PrimaryContactExpanded primaryContactExpanded;
private PrimaryContact primaryContact;
private String id;
private Status status;
public String getCode ()
{
return code;
}
public void setCode (String code)
{
this.code = code;
}
public String getLastActive ()
{
return lastActive;
}
public void setLastActive (String lastActive)
{
this.lastActive = lastActive;
}
public PrimaryContactExpanded getPrimaryContactExpanded ()
{
return primaryContactExpanded;
}
public void setPrimaryContactExpanded (PrimaryContactExpanded primaryContactExpanded)
{
this.primaryContactExpanded = primaryContactExpanded;
}
public PrimaryContact getPrimaryContact ()
{
return primaryContact;
}
public void setPrimaryContact (PrimaryContact primaryContact)
{
this.primaryContact = primaryContact;
}
public String getId ()
{
return id;
}
public void setId (String id)
{
this.id = id;
}
public Status getStatus ()
{
return status;
}
public void setStatus (Status status)
{
this.status = status;
}
//In order to deserialize it and fetch it through a list I have used the following code
List<MyPojo> customers = response.jsonPath().getList(".", MyPojo.class);
//System.out.println(response.jsonPath().get("primaryContactExpanded.companyName"));
for(MyPojo customer : customers)
{
System.out.println(customer.getId());
System.out.println(customer.getPrimaryContactExpanded().getDisplayAs());
}
It performs the deserialization of an json object into a list of MyPojo class
And I can fetch the values while iterating it through the list
How can I perform the same for IRestSharp response and deserialize it into a list of List of a class object and for each iteration fetch the values
I am not able to perform the same task in C#.