[#19, #21] Implement recursive toJSON compatibility