I am trying to do something in F #, as an example JsonConstructorAttributein the Json.NET documentation :
public class User
{
public string UserName { get; private set; }
public bool Enabled { get; private set; }
public User()
{
}
[JsonConstructor]
public User(string userName, bool enabled)
{
UserName = userName;
Enabled = enabled;
}
}
The analogue in F # looks something like this, but I get an error while posting [<JsonConstructor>]:
[<JsonConstructor>] // ERROR! (see below)
type User (userName : string, enabled : bool) =
member this.UserName = userName
member this.Enabled = enabled
Mistake
This attribute is not valid for use in this language element.
So how can I decorate the primary constructor [<JsonConstructor>]?
source
share