Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:10:06+00:00 2026-06-14T17:10:06+00:00

I have a certain json: [ { id : 42422422, created : 1329684013, name

  • 0

I have a certain json:

[
    {
        "id"        : 42422422,
        "created"   : 1329684013,
        "name"          : "Test"
    },
    {
        "id"        : 42422423,
        "created"   : 1329684015,
        "name"          : "Test 123"
    },
        {
          ...
        }
]

Parsing this goed OK, but when the webserver has an error, this JSON is returned:

{
    "error" : {
        "code"      : "511",
        "message"   : "JSON error",
        "extra" : {
            "some"      : "text",
            "someextra" : "text"
        }
    }
}

I’ve tried using this:

if ([jsonArray valueForKey:@"error"] != nil) {

but that doesn’t work, because if I output the value of that it’s an array of ‘null’s’

How can I check this? (I know I can use NSRange, but I think there has to be a better way right?

I parse the JSON like this:

NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error: &e]; 

responseData comes from the connectionDidFinishLoading method of NSURLConnection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:10:07+00:00Added an answer on June 14, 2026 at 5:10 pm

    You should check if your result is an array or a dictionary first.

    if ([jsonArray isKindOfClass:[NSArray class]]) {
         //process results
    } else if ([jsonArray isKindOfClass:[NSDictionary class]]) {
        NSDictionary *errorInfo = [(NSDictionary *)jsonArray objectForKey:@"error"];
        //handle error...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json array with certain objects : first name , last name,
I am parsing some JSON values. I have a NSDictionary and for a certain
I have an asp.net mvc website that returns a JSON result to certain pages
I have a certain object type that is stored in a database. This type
So I have this JSON object: [ { branch_id: 1, issue_id: 1, user_id: 5,
my situation is this: I have similar objects that differ in certain fields. Example:
I have a directory structure like this: root folder1 abc.json def.json somedir more.json folder2
I have created a JSON object in php using json_encode and am attempting to
I'm quite new to dojo, but I have a certain error dealing with the
I have the following code: function drawDimensions(divid) { // This function gets a JSON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.