JSON.stringify takes toJSON methods into consideration