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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:50:10+00:00 2026-06-02T11:50:10+00:00

I have task that involves creating the right design for the JSON string before

  • 0

I have task that involves creating the right design for the JSON string before I can get a response from the webservice. The JSON string has to look like this:

{"nid":"","vocab":"", "inturl":"testoverview", "mail":"", "md5pw":""}

and my JSON string looks like this:

"nid:",
"vocab:",
"inturl:testoverview",
"mail:",
"md5pw:"

as you can see it’s not built the same way, I’m not using braces, or separating the strings the right way. And I don’t know how to do this.

my code for this is here:

NSString *nid = @"nid:";
NSString *vocab = @"vocab:";
NSString *inturl = @"inturl:testoverview";
NSString *mail = @"mail:";
NSString *md5pw = @"md5pw:";

NSArray *jsonArray = [NSArray arrayWithObjects:nid, vocab, inturl, mail, md5pw, nil];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonArray options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];


FSProductTestHandler *handler = [[FSProductTestHandler alloc] init];

if (!jsonData) {
    NSLog(@"Got an error; %@", error);
} else if(jsonData) {

    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

    NSString *url = @"http://www.taenk.dk/services/mobile";
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLCacheStorageAllowed timeoutInterval:30.0];

    [request setValue:jsonString forHTTPHeaderField:@"X-FBR-App"];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];

}

Can anyone help me with this issue?

  • 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-02T11:50:12+00:00Added an answer on June 2, 2026 at 11:50 am

    You are feeding an array to the serialisation which means you’ll get a JSON array as output i.e soemthing like:

    [ "foo", "bar", "baz"]
    

    (note the brackets [ ...] instead of braces { ... })

    You need to build an NSDictionary and for your particular example, the quickest way is like this:

    NSDictionary* dictionary = [NSDictionary dictionaryWithObjectsAndKeys: 
                                    @"", @"nid",
                                    @"", @"vocab",
                                    @"testoverview", @"inturl",
                                    @"", @"md5pw", 
                                    @"", @"mail",
                                    nil];
    

    Feed that into NSJSONSerialization and you’ll get what you want.

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

Sidebar

Related Questions

I have a rake task that pulls and parses JSON data over an SSL
I have a simple task that I can't find a solution for, and I'm
I have inherited some code which involves a scheduled task that writes data (obtained
I have a task at work that involves converting legacy SGM files into XML.
I have a job right now that will never quit. It involves running a
I wrote a short bash script to complete a task that involves creating a
I need to automate a particular task that involves: Fetching mails from my mailbox
I have a task that takes a rather long time and should run in
I have a task that's driving me crazy because i have no clue where
Just stumbled upon propertyGrid and its awesome! However, i have one task that i

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.