1

I'm getting JSON back from a REST call. I've created a mapping called "Teacher", which has 3 properties in it. Nothing special.

Another object "Classroom", has a property to the teacher object. So it looks something like this:

classroom : {
   roomNumber : "123",
   floor: 2,
   id : "A123",
   teacher: {
       name: "John Doe",
       specialty: "Science",
       homeroom: "128"
   },
}

The problem I'm getting is that sometimes a classroom has no dedicated "teacher", and I'm getting an empty object from the service:

teacher: { }

When I get this, RestKit gives me a warning, "failed mapping nested object: (null)".

I realize that it would be better if the service were to return "null", or no teacher property at all. But until I can convince the server guys otherwise, is there a way I can tell RestKit to not worry if I get an object like this?

Dan Morrow
  • 4,433
  • 2
  • 31
  • 45
  • Did you get around this? I'm facing the same issue. Thx! – Andres C Sep 08 '15 at 15:47
  • 1
    I can't remember at this point, but I think I actually was able to get the service-guys to change their service! That said, you can fix this with RKDynamicMapping. If the object coming through is null, then you can create (in my example) a Teacher object, with no values set. – Dan Morrow Sep 09 '15 at 02:14

0 Answers0