Fix implementation of toJSON() call