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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:41:12+00:00 2026-05-24T04:41:12+00:00

I am attempting to connect to a web page and return a JSON string.

  • 0

I am attempting to connect to a web page and return a JSON string. This string simply needs to be parsed in JSON and returned into an NSArray that I have waiting for it. The problem is that JSON doesn’t always return the results. Sometimes, it works well. Sometimes, it returns (null), citing the error below.

self.accounts = nil; // Clear the NSArray

NSString *post = [NSString stringWithFormat:@"username=%@", username.text];
NSData *postData = [NSData dataWithBytes: [post UTF8String] length: [post length]];

// Submit login data
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString: @"http://###.#####.###/app/getaccts.php"]];
[request setHTTPMethod: @"POST"];
[request setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];
[request setHTTPBody: postData];

// Retreive server response
NSURLResponse *response;
NSError *err;
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *content = [NSString stringWithUTF8String:[returnData bytes]];

accounts = [[content JSONValue] allValues]; // Parse JSON string into the array
NSLog(@"Array: %@", accounts);

The page I am submitting to returns this:

{"1":"856069060", "2":"856056407"}

JSON logs the following error:

-JSONValue failed. Error is: Illegal start of token [r]
  • 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-24T04:41:13+00:00Added an answer on May 24, 2026 at 4:41 am

    Can I get a little more info … specifically, I’d like you to check the return value of your sendSynchronousRequest so can you make this change and rerun your test:

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
    if (returnData == nil) {
        NSLog(@"ERROR: %@", err);
    } else {
        NSLog(@"DATA: %@", returnData);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just attempting this question I found in a past exam paper so that I
I am attempting to implement xmpp chat/collaboration between two C# desktop clients that exchange
In attempting to run ./manage.py runserver or shell or any other command for that
while attempting to run rake, I run into the following error: heroku rake db:migrate
I have written a linux daemon that will be (and must be) running as
I am attempting to make a simple connection to a MySql database, located on
I'm attempting to pass a key via the $_SERVER['HTTP_REFERER'] (set via cURL) from one
I have a mod rewrite rule for pagination of my content: RewriteRule ^content/page/([^/]*)$ /index.php?page=$1
For the app that i am developing i have used a UISplitViewController as my
I have a python script using imaplib that connects to a gmail account and

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.