This sample uses the Argon.JsonConstructorAttribute
to specify that a constructor should be used to create a class during deserialization.
public class User
{
public string UserName { get; }
public bool Enabled { get; }
public User()
{
}
[JsonConstructor]
public User(string userName, bool enabled)
{
UserName = userName;
Enabled = enabled;
}
}
var json = """
{
"UserName": "domain\\username",
"Enabled": true
}
""";
var user = JsonConvert.DeserializeObject<User>(json);
Console.WriteLine(user.UserName);
// domain\username