I am creating a JSON file with Newtonsoft.Json from a set of classes. The file created is very large, so I have created JsonProperty\'s for the properties to re
Json support us to ignore property that don't want return. Example
class Foo
{
public int Id { get; set; }
public string Name { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string AlternateName { get; set; }
}
How to use it:
Foo foo = new Foo
{
Id = 1,
Name = "Thing 1",
AlternateName = null,
};
string json = JsonConvert.SerializeObject(foo);