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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:26:56+00:00 2026-05-26T11:26:56+00:00

I have a JSON response from my server. The data, taken from the RestKit

  • 0

I have a JSON response from my server.
The data, taken from the RestKit log looks like this:

sourceObject: ( 
    { 
    place =         { 
        "place_id" = "3cc1e372-f9d9-11e0-aba9-9415ab1a8034"; 
        placeinfo =             { 
            latitude = "12.5846738815"; 
            longtitude = "55.6815948486"; 
            "place_id" = "3cc1e372-f9d9-11e0-aba9-9415ab1a8034"; 
        }; 
        timestamp = "2011-10-19 00:33:44"; 
    }; 
}, 
    { 
    place =         { 
        "place_id" = "b65e36e0-f9d9-11e0-aba9-9415ab1a8034"; 
        placeinfo =             { 
            latitude = "12.5720376968"; 
            longtitude = "55.6785774231"; 
            "place_id" = "b65e36e0-f9d9-11e0-aba9-9415ab1a8034"; 
        }; 
        timestamp = "2011-10-19 00:37:08"; 
    }; 
}, 
    { 
    Timestamps =         { 
        "latest_update" = "2011-10-18 17:12:09"; 
        uuid = "8c6fb842-f99b-11e0-aba9-9415ab1a8034"; 
    }; 
} )and targetObject: (null) 

The data is mapped into 3 objects:

Place, Placeinfo and LatestDBUpdate.

The problem is:

In the above JSON response there are 2 place objects and 2 nested PlaceInfo objects,connected with a One To Many relationship.

There is also a LatestDBUpdate object that relates to the Timestamps keyword.

Restkit will map 3 Place objects, and one will be all NULL.
The 2 other Place objects are mapped correctly and relations are also correct.
It should of course only map 2 Place objects!

The LatestDBUpdate mapping s also mapping the Timestamps correct.

I have determined, that if i remove the Timestamps part of the JSON respons, then the mapping is correct, with only 2 place objects.

But i need the Timestamps part to be there!
I have no idea how to fix this! any ideas – I could really use some input, since i have used hours upon hours on this!

Here are the mapping setup used:

//Place mapping 
if (!self.placeManagedObject){ 
    self.placeManagedObject = [RKManagedObjectMapping mappingForClass:[Place class]]; 
    self.placeManagedObject.primaryKeyAttribute = @"UUID"; 
    self.placeManagedObject.setDefaultValueForMissingAttributes = YES; 
    [self.placeManagedObject mapKeyPath:@"place_id" toAttribute:@"UUID"]; 
    [self.placeManagedObject mapKeyPath:@"timestamp" toAttribute:@"timestamp"]; 
} 
//PlaceInformation mapping 
if (!self.placeInfoManagedObject){ 
    self.placeInfoManagedObject = [RKManagedObjectMapping mappingForClass:[PlaceInfo class]]; 
    self.placeInfoManagedObject.primaryKeyAttribute = @"UUID";self.placeInfoManagedObject.setDefaultValueForMissingAttributes = YES; 
    [placeInfoManagedObject mapKeyPath:@"place_id" toAttribute:@"UUID"]; 
    [placeInfoManagedObject mapKeyPath:@"longtitude" toAttribute:@"longtitude"]; 
    [placeInfoManagedObject mapKeyPath:@"latitude" toAttribute:@"latitude"]; 
} 
//latestDBUpdate timestamp mapping 
if (!self.latestDBUpdateManagedObject){ 
    self.latestDBUpdateManagedObject = [RKManagedObjectMapping mappingForClass:[LatestDBUpdate class]]; 
    self.latestDBUpdateManagedObject.primaryKeyAttribute = @"latest_update"; 
    [self.latestDBUpdateManagedObject mapKeyPath:@"latest_update"toAttribute:@"latest_update"]; 
    [self.latestDBUpdateManagedObject mapKeyPath:@"uuid" toAttribute:@"uuid"]; 
} 
//Set mapping relations 
[self.placeManagedObject mapRelationship:@"placeinfo" withMapping:self.placeInfoManagedObject]; 
// Register mapping with the provider - 
[self.objectManager.mappingProvider setMapping:self.placeManagedObject forKeyPath:@"place"]; 
[self.objectManager.mappingProvider setMapping:self.placeInfoManagedObject forKeyPath:@"placeinfo"]; 
[self.objectManager.mappingProvider setMapping:self.latestDBUpdateManagedObject forKeyPath:@"Timestamps"]; 
  • 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-26T11:26:57+00:00Added an answer on May 26, 2026 at 11:26 am

    Back again, with an answer to my own problem… Seems there are not many members here that use Restkit!

    My solution, maybe not pretty, but the only that worked, without
    removing the Timestamps part of the JSON response:

    I modified the JSON response in the following way:

    { 
    placeList =     ( 
                { 
            place =             { 
                "place_id" = "3cc1e372-f9d9-11e0-aba9-9415ab1a8034"; 
                placeinfo =                 { 
                    latitude = "12.5846738815"; 
                    longtitude = "55.6815948486"; 
                    "place_id" = "3cc1e372-f9d9-11e0-aba9-9415ab1a8034"; 
                }; 
                timestamp = "2011-10-19 00:33:44"; 
            }; 
        }, 
                { 
            place =             { 
                "place_id" = "b65e36e0-f9d9-11e0-aba9-9415ab1a8034"; 
                placeinfo =                 { 
                    latitude = "12.5720376968"; 
                    longtitude = "55.6785774231"; 
                    "place_id" = "b65e36e0-f9d9-11e0-aba9-9415ab1a8034"; 
                }; 
                timestamp = "2011-10-19 00:37:08"; 
            }; 
        } 
    ); 
    updateData =     { 
        timestamps =         { 
            "latest_update" = "2011-10-18 17:12:09"; 
            uuid = "8c6fb842-f99b-11e0-aba9-9415ab1a8034"; 
        }; 
    };} 
    

    Adding a kind of primary key for places -> placeList and updateData for timestamps.

    I also needed to change the keypath for the provider to reflect the change to the JSON input:

    // Register mapping with the provider - 
    [self.objectManager.mappingProvider setMapping:self.placeManagedObject forKeyPath:@"placeList.place"]; 
    [self.objectManager.mappingProvider setMapping:self.placeInfoManagedObject forKeyPath:@"placeinfo"]; 
    [self.objectManager.mappingProvider setMapping:self.latestDBUpdateManagedObject forKeyPath:@"updateData.timestamps"]; 
    

    So it solved it. No more NULL objects, mapped, even thou i do not
    quite understand why the change to the JSON makes such a big
    difference in the mapping.!

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

Sidebar

Related Questions

I am trying to parse a JSON response from a server using javascript/jquery. This
I have a JSON response that is formatted from my C# WebMethod using the
I have some JSON returned to the browser like this product: { Title: School
I have validated the JSON response from my C# Webmethod, so I don't believe
I am getting response from server side in the form of json array.I need
I have a simple resftul wcf service. The .svc file looks like this <%@
I am using PHP CURL to fetch data from a server. The response can
I use SBJsonParser for parsing a large json response I query from a server.
I have a jqGrid where I get data at once from server (java) in
I started getting errors in my browser, parsing JSON return data from the server.

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.