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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:41:55+00:00 2026-05-26T07:41:55+00:00

How to parse a a JSON string in iOS app? Using SBJSON. Running the

  • 0

How to parse a a JSON string in iOS app? Using SBJSON. Running the code below. Getting data is successful but the count on the number of entries in the array is zero even tho the JSON string contains entries. My question is how query the JSON string in a loop?

Thanks!

// Create new SBJSON parser object
SBJsonParser *parser = [[SBJsonParser alloc] init];

// Prepare URL request to download statuses from Twitter
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://safe2pee.org/api/proxlist.php?location=37.7626214,-122.4351661&distance=1"]];

// Perform request and get JSON back as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

// Get JSON as a NSString from NSData response
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

NSLog(@"string equal = %@", json_string);

// parse the JSON response into an object
// Here we're using NSArray since we're parsing an array of JSON b objects
NSArray *bathrooms = [parser objectWithString:json_string error:nil];

NSLog(@"count = %d", [bathrooms count]);

// Each element in bathrooms is a single bathroom
// represented as a NSDictionary
for (NSDictionary *bathroom in bathrooms)
{
    // You can retrieve individual values using objectForKey on the bathroom NSDictionary
    // This will print the tweet and username to the console
    NSLog(@"%@ - %@", [bathroom objectForKey:@"name"], [[bathroom objectForKey:@"lat"] objectForKey:@"long"]);
}
  • 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-26T07:41:55+00:00Added an answer on May 26, 2026 at 7:41 am

    It’s because it’s not working. That’s not a valid JSON string. That’s 2 JSON dictionaries, back to back, with a comma in between. It’s missing the wrapping []. If you actually test the result value of -objectWithString:error:, you’d see it’s nil, and if you pass in an NSError** to the error parameter there, you’d get back an error message telling you it’s invalid JSON.

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

Sidebar

Related Questions

I parse data using JSON in javascript, I find this is very convenient. But
I am trying to parse JSON in an Adobe Flex app, using http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3/'>This Tutorial
im getting response in json, but this wont parse the json response. what m
I am trying to deserialize a JSON string for an iOS app that I
I'd like to parse a JSON string into an object under Google App Engine
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I'm using the following code to get a JSON string that I'm going to
I'm trying to parse a simple JSON string, but I'm not used to do
Scenario: Ruby on Rails app that returns JSON to an iOS application using json-framework
I'm using the JSON framework in Obj-C (iOS) to parse responses from a RESTful

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.