TO_JSON: Make it actually work.

Before this, relationships were handled abysmally

Signed-off-by: Shea Levy <shea@shealevy.com>