How to read json
data using for each loop in C# ASP.NET. I have following output data of json
and i want to read red
highlighted data education
using foreach
loop.
Here is my json
data.
{
"data": {
"certifications": [],
"dateOfBirth": null,
"education": [
{
"id": 29364744,
"organization": "Texas A&M University",
"accreditation": {
"education": "Bachelor of Science",
"educationLevel": "bachelors",
"inputStr": "Bachelor of Science Computer Science",
"matchStr": ""
},
"grade": null,
"location": {
"formatted": "College Station, TX, USA",
"streetNumber": null,
"street": null,
"apartmentNumber": null,
"city": "College Station",
"postalCode": null,
"state": "Texas",
"country": "United States",
"rawInput": "College Station, TX",
"countryCode": "US",
"latitude": 30.627977,
"longitude": -96.3344068
},
"dates": {
"startDate": "2005-01-01",
"completionDate": "2009-01-01",
"isCurrent": false,
"rawText": "2005 - 2009"
}
}
]
}
}
var response = client.Post(request);
var json = response.Content.ToString();
var data = (JObject)JsonConvert.DeserializeObject(json);
3
Answers
Create a classes with the relevant properties and pass that type to DeserializeObject.
you could create a class with you json structure visual studio has one option
for that
After with json net you can deserialize the message
you can try something like this
output