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

  • Home
  • SEARCH
  • 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 3874308
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:13+00:00 2026-05-19T22:08:13+00:00

Could you please tell me how to pass a JSON String which looks like

  • 0

Could you please tell me how to pass a JSON String which looks like this:

{"lessons":[{"id":"38","fach":"D","stunde":"t1s1","user_id":"1965","timestamp":"0000-00-00 00:00:00"},{"id":"39","fach":"M","stunde":"t1s2","user_id":"1965","timestamp":"0000-00-00 00:00:00"}]}

I tried it like this:

SBJSON *parser =[[SBJSON alloc] init];
    NSArray *list = [[parser objectWithString:JsonData error:nil] copy];
    [parser release];
    for (NSDictionary *stunden in list)
    {
        NSString *content = [[stunden objectForKey:@"lessons"] objectForKey:@"stunde"];

    }

thanks in advance

best regards

  • 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-19T22:08:14+00:00Added an answer on May 19, 2026 at 10:08 pm

    Note that your JSON data has the following structure:

    1. the top level value is an object (a dictionary) that has a single attribute called ‘lessons’
    2. the ‘lessons’ attribute is an array
    3. each element in the ‘lessons’ array is an object (a dictionary containing a lesson) with several attributes, including ‘stunde’

    The corresponding code is:

    SBJSON *parser = [[[SBJSON alloc] init] autorelease];
    // 1. get the top level value as a dictionary
    NSDictionary *jsonObject = [parser objectWithString:JsonData error:NULL];
    // 2. get the lessons object as an array
    NSArray *list = [jsonObject objectForKey:@"lessons"];
    // 3. iterate the array; each element is a dictionary...
    for (NSDictionary *lesson in list)
    {
        // 3 ...that contains a string for the key "stunde"
        NSString *content = [lesson objectForKey:@"stunde"];
    
    }
    

    A couple of observations:

    • In -objectWithString:error:, the error parameter is a pointer to a pointer. It’s more common to use NULL instead of nil in that case. It’s also a good idea not to pass NULL and use an NSError object to inspect the error in case the method returns nil

    • If jsonObject is used only in that particular method, you probably don’t need to copy it. The code above doesn’t.

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

Sidebar

Related Questions

Could someone please tell me what is wrong with this code? It works fine
Could you please tell me what the equivalent BASH code for the following C++
Could anyone please tell me what the web developers can do with cloud computing,
Could you please tell me the difference between using asp.net validator controls vs JQuery
Could you please tell me, if it's possible to read Environment Variables using Javascript
Could you please tell me how to find the pixel co ordinates of a
I need to put flash uploader between form elements. Could you please tell me
<div>divbox</div> <p>para1</p> <p>para2</p> <p>para3</p> <table class=table><tr><td></td></tr></table> <p>para4</p> <p>para5</p> could someone please tell me how
Given a binary application running on linux PC. Is it possible to determine if
hello i am building a template in c++ ,and i need to overwrite the

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.