C# Json字符串和实体类class的相互转换
作者:互联网
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);
标签:实体类,string,C#,regUnlock,public,Json,RegUnLock 来源: https://www.cnblogs.com/heidashuaiGo/p/16454368.html