Fix crash when new pk is encountered multiple times within the same JSON.

New object should be registered for its pk before rest of JSON is enumerated.