toJSON refinements

Dear Oscar,

As a follow-up of my ticket, I forked your repo and added a refinement for the toJSON issue.

I hope you are ok with it.


Regards,

Imre