fixes #1: adding toJSON method so json will stringify correctly

Pulling into dev for now, will eventually roll this into master on the next release.