Fix for toJSON bug

Fixed issue with toJSON not working when called against a model with
links in nested scope that have not been followed (missing null check)