Abstract toJSON

Fixes #1599 


fixing #1637