Skythrust
Member
- Jul 9, 2019
- 133
- 7
Hi all,
I was wondering if there are any possibilities to show all values from an JSON output in a list.
For now I am able to show just one value, but in the foreach I would like to show them all.
with the [0] it works for just one record.
I was wondering if there are any possibilities to show all values from an JSON output in a list.
For now I am able to show just one value, but in the foreach I would like to show them all.
C#:
c#
JSON output/response is; [{"FrstName": "John","LastName": "Doe","MiddleName": null,},{"FrstName": "Jane","LastName": "Doe","MiddleName": null,},{"FrstName": "Hope","LastName": "Dyne","MiddleName": van,}]
dynamic jsonResponse = JsonConvert.DeserializeObject(response.Content);
Persons = new List<Person>();
Persons.Add(new Person()
{
FrstName = jsonResponse.FrstName, // FrstName = jsonResponse[0].FrstName
LastName = jsonResponse.LastName, // LastName = jsonResponse[0].LastName
MiddleName = jsonResponse.MiddleName, // MiddleName = jsonResponse[0].MiddleName
});
with the [0] it works for just one record.