now checking for the toJSON method before calling it