1、Json字符串转换为实体类
1 public class RegUnLock 2 { 3 /// <summary> 4 /// 医院编号 5 /// </summary> 6 public string hospitalCode { get; set; } 7 /// <summary> 8 /// 患者在医院的id 9 /// </summary> 10 public string patientId { get; set; } 11 } 12 13 var regUnLockInputDto = JsonConvert.DeserializeObject<RegUnLock>(reqData);
2、实体类转换为Json字符串
1 RegUnLock regUnlock=new RegUnLock(); 2 regUnlock.hospitalCode="1111"; 3 regUnlock.patientId="2222"; 4 5 string strJson = JsonConvert.SerializeObject(regUnlock);
原创文章,作者:bd101bd101,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/272627.html