❔ Assign JSON API Results To DTO

hey if I am returning json data from an API how do I assign the json data to my DTO? Meaning if I have a DTO that looks like this
public class TestDTO
{
   public Data data { get; set; }
}
public class Data
{
   public string fname { get; set; }
   public string lname { get; set; }
   public string phonenNumber { get; set; }
}
but I only want to assign a value to fname and lname how would I set that up?

TestDTO td = null;

//code here

td = new TestDTO
{
    //how do I get to fname here?
};
Was this page helpful?