| NullValueHandling Enumeration |
Namespace:
Newtonsoft.Json
Assembly:
Newtonsoft.Json (in Newtonsoft.Json.dll) Version: 12.0.1+509643a8952ce731e0207710c429ad6e67dc43db
Syntax public enum NullValueHandling
Members
| Member name | Value | Description |
---|
| Include | 0 |
Include null values when serializing and deserializing objects.
|
| Ignore | 1 |
Ignore null values when serializing and deserializing objects.
|
Examples public class Movie
{
public string Name { get; set; }
public string Description { get; set; }
public string Classification { get; set; }
public string Studio { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<string> ReleaseCountries { get; set; }
}
NullValueHandling Ignore Example
Movie movie = new Movie();
movie.Name = "Bad Boys III";
movie.Description = "It's no Bad Boys";
string included = JsonConvert.SerializeObject(movie,
Formatting.Indented,
new JsonSerializerSettings { });
string ignored = JsonConvert.SerializeObject(movie,
Formatting.Indented,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
See Also