Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.24 KB

File metadata and controls

35 lines (29 loc) · 1.24 KB

JsonIgnoreAttribute

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

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

    [JsonIgnore] public string PasswordHash { get; set; }
}

snippet source | anchor

var account = new Account
{
    FullName = "Joe User",
    EmailAddress = "joe@example.com",
    PasswordHash = "VHdlZXQgJ1F1aWNrc2lsdmVyJyB0byBASmFtZXNOSw=="
};

var json = JsonConvert.SerializeObject(account);

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

snippet source | anchor