Added support for toJSON interface.