JSON.NET serialize JObject while ignoring null properties

后端 未结 4 1890
说谎
说谎 2020-12-01 16:37

I have a JObject which is used as a template for calling RESTful web services. This JObject gets created via a parser and since it

4条回答
  •  鱼传尺愫
    2020-12-01 17:08

    You can prevent the null tokens from being created to begin with by specifying the JsonSerializer with its NullValueHandler set to NullValueHandler.Ignore. This is passed in as a parameter to JObject.FromObject as seen in an answer to the same question you linked to: https://stackoverflow.com/a/29259032/263139.

提交回复
热议问题