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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:25:42+00:00 2026-05-31T11:25:42+00:00

I am developing an application for both Android and iPhone and I am having

  • 0

I am developing an application for both Android and iPhone and I am having a problem marshalling and unmarshalling on iPhone. With Android it is easy enough, I am using Jackson JSON parser and there are plenty of tutorials online which made it easy to use.

On the iPhone I am using SBJSON parser, however there seems to be a real lack of information online about how to use it effectively.

Take the following piece of JSON

{
"data":{
    "name":[
            {
            "fName":"John",
            "lName":"Doe"
            },
            {
            "fName":"Jane",
            "lName":"Doe"
            }
            ]
}
}

If I were using Java and using Jackson JSON parser, this would be easy. I would set up a Class like

public class Parse {

private Data data;

//get set data class

Then in the data class

public class Data {

private List<Name> name;

//get set name list

then in the name class

public class Name {

private String fName;
private String lName;

//get setters here

That way I have the data split up into a set of objects so I can retrieve the data I need, I can update the JSON if required from Java, then write it out again into a new JSON file, nice and simple, i.e

ObjectMapper mapper = new ObjectMapper();

    Parse test = mapper.readValue(new File("/Users/adam/Documents/JSON/list.json"),
            Parse.class);

    System.out.println(test.getData().getName().get(0).getfName());

or I could set it doing

test.getData().getName().get(0).setfName("test");

What I want to know, is how do I do this with Xcode using SBJSON. I know how to do parse the data, and print it out, but I want to be able to print it out into a set of objects, make a change, then write it out again as I can with Jackson JSON parser. What I have done is

  NSString *file = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"json"];  
 NSData *Data = [NSData dataWithContentsOfFile:file];  
 NSString *jsonString = [[NSString alloc] initWithData:Data encoding:NSUTF8StringEncoding];


 NSDictionary *dictionary = [jsonString JSONValue];

NSArray *name = [dictionary valueForKeyPath:@"data.name"];

NSLog(@"%@", name);

This will get the array of names, but I want to be able to access the first name and last name of each objects, and then update it if I require. Then Write it out again.

Would anyone be able to point me in the right direction. Is it possible to do the same sort of thing I did with Jackson JSON with SBJSON?

  • 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-31T11:25:43+00:00Added an answer on May 31, 2026 at 11:25 am

    Found out how to do it.

    Make a class Called List

    @interface List : NSObject{
      NSString *fName;
      NSString *lName;
    }
    
    @property (nonatomic, retain) NSString *fName;
    @property (nonatomic, retain) NSString *lName;
    
    @end
    

    Then implementation synthesise

    @synthesize fName, lName;
    

    Then code to create object of List and loop through it

    NSMutableArray *array = [[NSMutableArray alloc] init];
    List * list;
    NSArray * listArray = [MainJSON valueForKeyPath:@"data.name"];
    
    for(NSDictionary * listInfo in listArray) {
        list = [[List alloc] init];
        [list setFName:[listInfo objectForKey:@"fName"]];
        [list setLName:[listInfo objectForKey:@"lName"]];
        [array addObject:list];
    }
    
    for (int i = 0; i < [array count]; i++) {
        List* l = [array objectAtIndex: i];
        NSLog(@"%@", [l fName]);
        NSLog(@"%@", [l lName]);
    }
    

    Hope this helps anyone else who was trying to do the same thing I was.

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

Sidebar

Related Questions

I'm developing an application both for Iphone and Andriod using Phonegap. I came up
I am developing an android game application played using bluetooth. While searching for bluetooth
Developing an application using SWT to work in both Linux and Windows. I created
I'm developing an application that is supposed to run on both Android as well
I am developing android push notification application using C2DM,I am facing some problems in
I’m using PDK 7.3 as a development tool for developing an application using both
I am developing application on both 10'inch&7'inch tablets, here is my problem for 10'inch
I am developing application for iPhone and iPad both, its working fine in iPhone
I am using Titanium appcelerator for developing my android application, more over i am
I am developing hybrid application by using webview and native both. I am using

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.