quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

How to Read Nested JSON?

Open MrDevDevy opened this issue 3 years ago • 0 comments

Hello,

I have a nested JSON file that looks something like this

"FirstName":"Adam","Relatives":{"Males":{"Brothers":{"label":"Brothers of Adam"... etc.

I am able to access the the string "Adam" using Newtonsoft JSON writing something like this

class Company
{
    [JsonProperty("FirstName")]
    public string FirstName{ get; set; }
}
...
var getFirstName= client.GetStringAsync(apiLink);
MyClass result = JsonConvert.DeserializeObject<MyClass>(await getFirstName);
Console.Out.WriteLine("First Name: " + getFirstName);

However, I am stumped how one would write the code to get Everything past relatives like Males, Brothers, and output the label "Brothers of Adam". Any help would be appreciated. Thanks!

MrDevDevy avatar Aug 11 '22 07:08 MrDevDevy