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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:44:22+00:00 2026-06-05T05:44:22+00:00

Is it possible to use key mapping with the following JSON structure or are

  • 0

Is it possible to use key mapping with the following JSON structure or are we going to have to perform looping through values manually? Examples would be great. Their rest api doesn’t really map real world objects into a standard object structure, but just modeled after the XML attributes. 🙁

THINGS{
"lastModifiedDate": "2012-02-23-08.43.16.916000",
"myList": [{
  "attributeList": [
                    {"id": "","name": "Content Level","val": "Introductory"},
                    {"id": "","name": "Session Type","val": "Business Overview"},
                    {"id": "20110616053537016","name": "Speaker","val": "Jim Kim, Company1"},
                    {"id": "20110616053526559","name": "Speaker","val": "Bob Ironman, Company2"},
                    {"id": "20110803145027914","name": "Speaker","val": "Kristine Thomas, Company3"},
                    {"id": "","name": "Room","val": "Banyan"},
                    {"id": "","name": "Industry","val": "Cross Industry"},
                    {"id": "","name": "Loc","val": "Stadium I"},
                    {"id": "","name": "Topic Tag","val": "CMS Systems"},
                    {"id": "","name": "Status","val": "Accepted"},
                    {"id": "","name": "Sub-Event","val": "Leadership"},
                    {"id": "","name": "Session","val": "LVI"},
                    {"id": "","name": "SubTrack","val": "None"},
                    {"id": "","name": "Track","val": "Business Value Outsourcing"}
  ],

"active": true,
"desc": "This is a really cool thing",
"end": "16:00",
"id": "2011080146112",
"num": "1002A",
"start": "15:00",
"title": "The thing title"
  }
 ]
}
  • 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-05T05:44:22+00:00Added an answer on June 5, 2026 at 5:44 am

    Yes it is possible with RestKit.

    You can get all documentation you need reading this article from the official wiki and here you have an explanation for doing what you need. Hope this helps you!

    First you will need three objects for each entity, one for the ThingsList, another for representing one Thing and another for representing one ThingAttribute. Let’s start by the most basic element, the ThingAttribute:

    SOAttribute.h

    #import <Foundation/Foundation.h>
    
    @interface SOAttribute : NSObject{
        NSNumber *attributeId; //I use this nomenclature because the word 'id' is reserved, same for other objects.
        NSString *name;
        NSString *val;
    }
    
    @end
    

    SOAttribute.m

    @implementation SOAttribute
    @end
    

    This will let you to represent this part of the JSON:

    {"id": "","name": "Content Level","val": "Introductory"}
    

    Now we will define the Thing as follows:

    SOThing.h

    #import <Foundation/Foundation.h>
    
    @interface SOThing : NSObject{
    
        NSArray *attributeList; //This represent the list of attributes defined before
        BOOL active;
        NSString *desc;
        NSString *title;
        NSString *end;
        NSString *start;
        NSString *num;
        NSNumber *thingId;
    
    }
    
    @end
    

    SOThing.m

    #import "SOThing.h"
    @implementation SOThing
    @end
    

    As you can notice, you have to define the attributeList as an NSArray. RestKit automatically will know that you need to receive a list of attributes there. So we have defined the following structure:

    {
        "attributeList": [...],
        "active": true,
        "desc": "This is a really cool thing",
        "end": "16:00",
        "id": "2011080146112",
        "num": "1002A",
        "start": "15:00",
        "title": "The thing title"
    }
    

    Finally you define the Thing List as follows:

    SOThingList.h

    #import <Foundation/Foundation.h>
    
    @interface SOThingList : NSObject{
        NSDate *lastModifiedDate;
        NSArray *myList;
    }
    @end
    

    SoThingList.m

    #import "SOThingList.h"
    @implementation SOThingList
    @end
    

    As before, we need a list of Things so we define myList as an NSArray.

    Now, that was easy, here comes the magic where you indicate to RestKit how to map each entity.
    On your App Delegate put the following code:

    #import "SOThingList.h"
    #import "SOThing.h"
    #import "SOAttribute.h"
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    
    
        RKObjectMappingProvider *mappingProvider = [RKObjectManager sharedManager].mappingProvider;
    
        RKObjectMapping *mappingForAttribute = [RKObjectMapping mappingForClass:[SOAttribute class]];
        //This can be mapped directly
        [mappingForAttribute mapAttributes:@"name",@"val", nil];
        //here you indicate the special case, id->attributeId on our object
        [mappingForAttribute mapKeyPath:@"id" toAttribute:@"attributeId"];
        //Set the new mapping into the mapping provider.
        [mappingProvider addObjectMapping:mappingForAttribute];
    
        RKObjectMapping *mappingForThing = [RKObjectMapping mappingForClass:[SOThing class]];
        //Same as before, these attributes can be mapped directly
        [mappingForThing mapAttributes:@"active",@"title",@"end",@"start",@"desc",@"num", nil];
        [mappingForThing mapKeyPath:@"id" toAttribute:@"thingId"];
        //Here I indicate that any object on NSArray on attributeList should be mapped using SOAttribute mapping defined above.
        [mappingForThing mapKeyPath:@"attributeList" toRelationship:@"attributeList" withMapping:mappingForAttribute];
        [mappingProvider addObjectMapping:mappingForThing];
    
        RKObjectMapping *mappingForThingsList = [RKObjectMapping mappingForClass:[SOThingList class]];
        [mappingForThingsList mapAttributes:@"lastModifiedDate", nil];
        [mappingForThingsList mapKeyPath:@"myList" toRelationship:@"myList" withMapping:mappingForThing];
        [mappingProvider addObjectMapping:mappingForThingsList];
    
    }
    

    After all the above, you can get your Thing List with the following method using blocks:

    SomeObject.m

    - (void) get: (NSString *) resourcePath onLoad:(RKObjectLoaderDidLoadObjectBlock) loadBlock onError:(RKRequestDidFailLoadWithErrorBlock)failBlock{
    
        RKObjectMapping *mapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[SOThingList class]];
        [[RKObjectManager sharedManager] loadObjectsAtResourcePath:resourcePath usingBlock:^(RKObjectLoader* loader) {
            loader.objectMapping = mapping;
            loader.delegate = self;
            loader.onDidLoadObject = loadBlock;
    
            loader.onDidFailWithError = ^(NSError * error){
                NSLog(@"%@",error);
            };
            loader.onDidFailLoadWithError = failBlock;
            loader.onDidLoadResponse = ^(RKResponse *response) {
                //Do something
            };
    
        }];
    
    }
    

    And you use it like this…

    [someObjectInstance get:@"http://mydomain.com/mywebservice/" onLoad:^(id object){
        SOThingList *thingList = (SOThingList *) object;
        //Do something with your shiny thingList
    } onError:^(NSError *error) {
        //Display an error message :)
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Comparing functionality between KeyListeners and Key Bindings I've been trying to use
Is it possible use a MySQL query to perform this kind of check? If
Is it possible to use an object as a key for a Dictonary<object, ...>
Is it not possible to use the Pause/Break key in keyboard shortcuts? I know
Is it possible to use Enter key to break lines in Silverlight's AutocompleteBox ?
Possible Duplicate: Is it okay to use array[key] in PHP? Is there any significant
Is it possible to use a local index as a primary key in Oracle,
Is it possible to use a jQuery element object as an array/object key? Example:
I am wondering if is possible to implement following domain model. Let's have a
I use the mapping plugin with my own prototype types From JSON var mapping

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.