Updated ToJson method