Click or drag to resize
Json.NET

JsonIgnoreAttribute

 

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

Sample
Types
public class Account
{
    public string FullName { get; set; }
    public string EmailAddress { get; set; }

    [JsonIgnore]
    public string PasswordHash { get; set; }
}
Usage
Account account = new Account
{
    FullName = "Joe User",
    EmailAddress = "joe@example.com",
    PasswordHash = "VHdlZXQgJ1F1aWNrc2lsdmVyJyB0byBASmFtZXNOSw=="
};

string json = JsonConvert.SerializeObject(account);

Console.WriteLine(json);
// {"FullName":"Joe User","EmailAddress":"joe@example.com"}