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 6339421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:38:45+00:00 2026-05-24T19:38:45+00:00

I am currently trying to work with json and objective-c however having a bit

  • 0

I am currently trying to work with json and objective-c however having a bit of difficulty. The following is the json that is being returned

{
    sethostname =     (
    {
        msgs = "Updating Apache configuration\nUpdating cPanel license...Done. Update succeeded.\nBuilding global cache for cpanel...Done";
        status = 1;
        statusmsg = "Hostname Changed to: a.host.name.com";
        warns =             (
        );
    });
}

I am able to check that the response is coming back and the key is sethostname however no matter what I try I cannot get for example the value of status or statusmsg. Can anyone point me in the right location. The following is basic code I am using to check that sethostname is returned.

NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&myError];
NSLog([res description]);
NSArray *arr;
arr = [res allKeys];
if ([arr containsObject:@"sethostname"])
{
    NSLog(@"worked");
}
  • 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-05-24T19:38:46+00:00Added an answer on May 24, 2026 at 7:38 pm

    When in doubt, write down the structure of your JSON data. For example:

    {
        sethostname =     (
        {
            msgs = "Updating Apache configuration\nUpdating cPanel license...Done. Update succeeded.\nBuilding global cache for cpanel...Done";
            status = 1;
            statusmsg = "Hostname Changed to: a.host.name.com";
            warns =             (
            );
        });
    }
    

    (which is in NeXTSTEP property list format, actually) means that you have a top-level dictionary. This top-level dictionary contains a key called sethostname whose value is an array. This array is comprised of dictionaries, each dictionary having a set of keys: msgs, status, statusmsg, warns. msgs has a string value, status has a number value, statusmsg has a string value,warns` has an array value:

    dictionary (top-level)
        sethostname (array of dictionaries)
            dictionary (array element)
                msgs (string)
                status (number)
                statusmsg (string)
                warns (array)
                    ??? (array element)
    

    Having understood this structure, your code should look like:

    NSError *myError = nil;
    NSDictionary *res = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&myError];
    
    if (!res) { // JSON parser failed }
    
    // dictionary (top-level)
    if (![res isKindOfClass:[NSDictionary class]]) {
        // JSON parser hasn't returned a dictionary
    }
    
    // sethostname (array of dictionaries)
    NSArray *setHostNames = [res objectForKey:@"sethostname"];
    
    // dictionary (array element)
    for (NSDictionary *setHostName in setHostNames) {
        // status (number)
        NSNumber *status = [setHostName objectForKey:@"status"];
    
        // statusmsg (string)
        NSString *statusmsg = [setHostName objectForKey:@"statusmsg"];
    
        …
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently having an issue where I have a javascript object that is trying
I'm trying to make a WCF service that will work with JSON-P (long-story short,
I am currently trying out Json.NET , and it seems to work well. Any
I ask this because I am currently trying to work out my own technique,
Hey all, here is the issue I am currently trying to work through. We
I'm currently trying to get a UISlider to work. I'm trying to set the
Erlang version: R13B01 Currently I'm struggling trying to make Erlang work with SSL. The
I currently trying to find a solution, how to ensure that a test fails
With reference to Parse JSON in C# I am trying to parse the following
i'm trying to create a test module to test json encoding. i am having

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.