Click or drag to resize
Json.NETJsonIgnoreAttribute
 

This sample uses the JsonIgnoreAttribute to exclude a property from serialization.

Sample
Types
1public class Account
2{
3    public string FullName { get; set; }
4    public string EmailAddress { get; set; }
5
6    [JsonIgnore]
7    public string PasswordHash { get; set; }
8}
Usage
 1Account account = new Account
 2{
 3    FullName = "Joe User",
 4    EmailAddress = "joe@example.com",
 5    PasswordHash = "VHdlZXQgJ1F1aWNrc2lsdmVyJyB0byBASmFtZXNOSw=="
 6};
 7
 8string json = JsonConvert.SerializeObject(account);
 9
10Console.WriteLine(json);
11// {"FullName":"Joe User","EmailAddress":"joe@example.com"}