Fix Issue ##360: Added a toJSON function to the http module to allow customizing how objects are converted