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

The Archive Base Latest Questions

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

Im having a problem with the mapping of the: latest_update field in the JSON

  • 0

Im having a problem with the mapping of the: latest_update field in
the JSON data.

Recieving this JSON data from my webservice:

{"Places":[ 
    {"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974979a", 
     "timestamp": "2011-10-02 23:24:42" 
    }, 
    {"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974933x", 
     "timestamp": "2011-10-02 23:24:42" 
    }, 
    {"latest_update":"2011-10-13 12:16:17"}] 

}

And a snip of the code i use for the managed mapping:

 //Place mapping 
    if (!self.placeManagedObject){ 
        self.placeManagedObject = [RKManagedObjectMapping 
mappingForClass:[Place class]]; 
        self.placeManagedObject.primaryKeyAttribute = @"UUID"; 
        self.placeManagedObject.rootKeyPath = @"places"; 
        [self.placeManagedObject mapKeyPath:@"place_ID" 
toAttribute:@"UUID"]; 
        [self.placeManagedObject mapKeyPath:@"timestamp" 
toAttribute:@"timestamp"]; 
        [self.placeManagedObject mapRelationship:@"PlaceInformation" 
withMapping:self.placeInfoManagedObject]; 
        // Register mapping with the provider - means it will look for 
places in the JSON input 
        [objectManager.mappingProvider 
setMapping:self.placeManagedObject forKeyPath:@"places"]; 
    } 
    //latestDBUpdate timestamp mapping 
    if (!self.latestDBUpdateManagedObject){ 
        self.latestDBUpdateManagedObject = [RKManagedObjectMapping 
mappingForClass:[LatestDBUpdate class]]; 
        self.latestDBUpdateManagedObject.primaryKeyAttribute = 
@"latest_update"; 
        self.latestDBUpdateManagedObject.rootKeyPath = @"places"; 
        [self.latestDBUpdateManagedObject mapKeyPath:@"latest_update" 
toAttribute:@"latest_update"]; 
        // Register mapping with the provider - means it will look for 
places in the JSON input 
        [objectManager.mappingProvider 
setMapping:self.latestDBUpdateManagedObject 
forKeyPath:@"latest_update"]; 
    } 

RestKit will map the Place objects correct i.e:
{“place_ID”: “7cceedda-ed3a-11e0-a1a8-858e3974979a”,
“timestamp”: “2011-10-02 23:24:42”
}
…
into place objects,
but the latest_update is not mapped into the
LatestDBUpdate class object, and i cannot in any way get it to work.

I hope the someone has the answer to how it is done, because hours of
searching and trying has brought me no closer to a solution.
Thanx Thomas

  • 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:38:32+00:00Added an answer on May 26, 2026 at 7:38 am

    So i finally figured it out.
    Basically some small tweaks, and a couple of errors on my behalf:-/

    So i changed the JSON output from my webservice to this formatting:

    {"Places":[ 
    {"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974979a", 
     "timestamp": "2011-10-02 23:24:42" 
    }, 
    {"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974933x", 
     "timestamp": "2011-10-02 23:24:42" 
    }], 
    "Timestamps":[
    {"latest_update":"2011-10-13 12:16:17"}]
    

    I had a an error in the mapping og Timestamps -> latest_update, so i fixxed that:

    //latestDBUpdate timestamp mapping
    if (!self.latestDBUpdateManagedObject){
        self.latestDBUpdateManagedObject = [RKManagedObjectMapping mappingForClass:[LatestDBUpdate class]];
        self.latestDBUpdateManagedObject.primaryKeyAttribute = @"latest_update";
        self.latestDBUpdateManagedObject.rootKeyPath = @"Timestamps";
        [self.latestDBUpdateManagedObject mapKeyPath:@"latest_update" toAttribute:@"latest_update"];
    
        // Register mapping with the provider - means it will look for the keyword Timestamps in the JSON input
        [self.objectManager.mappingProvider setMapping:self.latestDBUpdateManagedObject forKeyPath:@"Timestamps"];
    

    And then i had a major error in my get method. Basically i told RestKit that the response should only be mapped by my Place mapping and thus not check all other data in the JSON input for other keywords.
    Just to show the difference i present both GET methods i used. The first will ONLY map with the specified mapping scheme, and number two will check with all registred mapping schemes:

    GET method number 1: (That does not work in the above context!)

    [[RKObjectManager sharedManager] loadObjectsAtResourcePath:gPlaceListBaseUrl objectMapping:self.placeManagedObject delegate:self];
    

    GET method numer 2: (Here all mapping schemes are checked and both Place objects are mapped, as well as my LatestDBUpdate object!)

    [[RKObjectManager sharedManager] loadObjectsAtResourcePath:gPlaceListBaseUrl delegate:self];
    

    Hopefully someone might need this someday:-D

    Thomas

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

Sidebar

Related Questions

I'm having a problem in mapping an existing data class member to the database..
I am having a problem mapping. I was reading scottGU post of data shaping
I'm having this problem using the knockout.mapping plugin in conjunction with RequireJS. Basically, the
I am having some problem mapping my Java Data Type to standard Schema Date
I'm having a problem mapping a JSON array generated by .NET JavaScriptSerializer , to
I am using XML Data Mapping and having a problem with generating complex types
I'm having a problem with the knockout-mapping plugin with IE8. Our situation is that
Having problem with this bit of code qith jQuery. it should pick the values
Having odd problem with mapping tables with code-first EF. I have a parent class
I'm having a problem getting FluentNHibernate's HasMany<> mapping to behave as I would expect.

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.