Revert "replace toJSON"

This reverts commit e5bdcdd2504dccbecd369e027590c0c2f796647f.