Added `toObject` methods to return an `object` and modified `toJSON` to return a `string`. Closes #732