Reputation: 421
I need to get value for error under results In the following json which I've got in a JObject :
{
"multicast_id": 6958024579437543738,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "NotRegistered"
}
].
}
I've tried things like
JArray errors = (JArray)o["results"];
string errorMessage = (string)o["results"]. ["error"];
But it cannot get the correct result.
Upvotes: 1
Views: 1170
Reputation: 1563
Try:
var errors = o["results"][0];
string errorMessage = (string)errors["error"];
That should give you the "NotRegistered" string.
Upvotes: 2