Adding a toJSON method to collections.