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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:51:03+00:00 2026-06-06T16:51:03+00:00

This is the json coming from the server: { name:channelname, args: [ { username:myusername,

  • 0

This is the json coming from the server:

{
    "name":"channelname",   
    "args":
    [
        {           
            "username":"myusername",
            "message":"mymessage"
        }
    ]
} 

Using ios5 built-in json methods I try to parse out the args’s username/message.

NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [packet.data dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers error: nil];
NSDictionary *argsValues = [[NSDictionary alloc] initWithDictionary:[JSON objectForKey:@"args"]];

Second line throws an error:

dictionary argument is not an NSDictionary

When I NSlog [JSON objectForKey@”args”] I get:

(
    {
        message = mymessage;
        username = myusername;
    }
)

I think the parenthesis are breaking it, don’t know where they came from, help appreciated.

EDIT:

Thanks to chosen answer, here’s the code I used to get the args keys.

NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [packet.data dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableLeaves error: nil];
NSArray *argsArray = [[NSArray alloc] initWithArray:[JSON objectForKey:@"args"]];
NSDictionary *argsDict = [[NSDictionary alloc] initWithDictionary:[argsArray objectAtIndex:0]];
NSLog(@"keys = %@", [argsDict allKeys]);
  • 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-06T16:51:04+00:00Added an answer on June 6, 2026 at 4:51 pm
    [json objectForKey:@"args"]
    

    is an NSArray. You can’t initialize an NSDictionary directly with an array.

    (in JSON, { and } denote key-value pairs, like NSDictionary, whereas [ and ] delimit ordered lists like NSArray, that’s why the mapping is done as it is…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view model coming from the server as json like this {
I use this code to process a date string coming in from a json
I'm getting this json string info from the server : {members:[[sd2840d,Johny],[jkld341,Marry]]} So I store
I have a JSON array coming in from the server with an array of
I tried to populate google chart datatable in server side using PHP.I got JSON
I fetch a json object from the server and populate my view. I then
I am using PHP + CURL to fetch data from a server in one
I'm trying to use JSON, I'm getting the information from the server so I've
I'm mapping JSON-formatted data from a web server to Objective C classes (NSManagedObjects modeled
I have built a test app on android using this cool-ass PhoneGap framework, but

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.