I have the following JArray object (newtonsoft.json)
[
{
"Administrator": 3
},
{
"User": 1
},
{
"Guest": 5
}
]
How do I retrieve the value (3) for key "Administrator" ? It's asking me for an array index but I would like to retrieve by key.. as this list can expand and contract..
Using Json.Net you can simply do
int value = (int)JArray.Parse(json).Children()["Administrator"].First();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With