Recursive toJSON assumes that all relations exist

Added a quick failing test.