'How do I call a specific piece of json data in a foreach loop?
(sorry for the bad title) I have this json file
[
{
"userId": 3017221209,
"displayName": "Frank"
},
{
"userId": 1690049096,
"displayName": "dumb"
}
]
And I deserialized it with this
var userss = System.Text.Json.JsonSerializer.Deserialize<List<User>>(json);
But I tried to mention it in a foreach loop (like for each user id do this and that) but I couldn't figure it out
foreach (var usersstuff in userss) { /* other stuff you are not supposed to see */ }
So.. any help?
Solution 1:[1]
You can't use User like a variable if it's name's class, try this:
foreach (var user in userss) { /* other stuff you are not supposed to see */ }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nicolas Quintana |
