Ignore NULL values in JsonConvert.Deserialize or JToken.Parse

27 Views Asked by At

For example, I have following JSON: {"a":null} and I want to deserialize it to Newtonsoft's JToken.

I tried JToken jt = JToken.Parse(json) and JToken jt = JsonConvert.DeserializeObject<JToken>(json, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) but both produce jt["a"] != null and jt["a"].Type == JTokenType.Null. Is it possible to make jt["a"] == null? Or maybe I'm asking some kind of nonsense?

0

There are 0 best solutions below