我想要我的类类型的 JSON 表示,以便我可以将它们插入客户端模式。这就是我的服务器端 C# 类的样子:
public class Person
{
public int ID { get; set; }
[Required(ErrorMessage = "Name is required.")]
public string Name { get; set; }
public DateTime Birthday { get; set; }
public bool IsMarried { get; set; }
}
我如何将它序列化为这个?:
{
fields: {
"ID": {
type: "number"
},
"Name": {
type: "string",
validation: {
required: true,
message: "Name is required.",
}
},
"Birthday": {
type: "date"
},
"IsMarried": {
type: "bool"
}
}
}