Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当该字段为空时,JsonConvert 是否可以不序列化该字段?
JsonConvert.SerializeObject(yourObj, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
是的。查看 JsonSerializerSettings 及其 NullValueHandling 属性。