C#对象转json

 

object obj = new
                    {
                        Provider = appointmentErpStoreEntity.ProvinceName,
                        City = appointmentErpStoreEntity.CityName,
                        District = appointmentErpStoreEntity.CountyName,
                        Address = appointmentErpStoreEntity.Address
                    };
                    addressInfo = JsonConvert.SerializeObject(obj);

如果赋值为null,一样可以转换成json

变成:{“Provider”:null,”City”:null........}

posted on 2022-10-28 17:33  Jankie1122  阅读(111)  评论(0编辑  收藏  举报