0

I want to read the jsons nested array from a HTTP Response using VB.Net or C#.

For Example I want to get the Name:

{
"Name": "Brian",
"address": {
   "street": "8nd Roadstreet"
 }
}

I've been using VB.Net so far, and it works using the following Code:

Using streamReader = New StreamReader(httpResponse.GetResponseStream())
    Json1 = JObject.Parse(streamReader.ReadToEnd())("Name")
    MessageBox.Show("Json Text:" & Json1.ToString)
End Using

Output is: Brian

But I don't know how to get the Street. Using the same Code above doesn't work as the Street is in the Address.

Would be great if someone could help me out here.

0

1 Answer 1

0

Create a class for the Http Response like below .

  public class Address    {
        public string street { get; set; } 
    }

    public class Root    {
        public string Name { get; set; } 
        public Address address { get; set; } 
    }

And You can use Newtonsoft to deserialize the Json .

Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.