1

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.

2
  • The "error" map object is the first element of "results" array. I think you mistake the "results" array as a map. Commented Oct 18, 2012 at 8:32
  • Thanks All. Helped me fix the problem! I was pretty close I see.... :) Commented Oct 18, 2012 at 8:36

1 Answer 1

2

Try:

var errors = o["results"][0];
string errorMessage = (string)errors["error"];

That should give you the "NotRegistered" string.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.