我正在Student
使用json.net
.
我想向序列化对象添加一个属性(称为cheak
不是Student
该类的成员。
这是班级学生:
public class Student
{
public int ID { get; set; }
[JsonIgnore]
public Faculty Faculty { get; set; }
[JsonProperty("Faculty")]
public string FacultyName { get { return Faculty.name; } }
public double AVG { get; set; }
public DateTime DateOfBirth { get; set; }
public string EducationInfo { get; set; }
public string FatherName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MotherName { get; set; }
public string Password { get; set; }
public string PersonalInfo { get; set; }
}
json:
{
"ID": 24,
"Faculty": "engen ",
"AVG": 3.0,
"DateOfBirth": "1990-02-02T00:00:00",
"EducationInfo": "GOOD",
"FatherName": "EEWF",
"FirstName": "FFEWR",
"LastName": "ERF",
"MotherName": "ERF",
"Password": null,
"PersonalInfo": "ERF",
}
我想将属性“cheak”添加到序列化对象中:
{
**cheak:true
"ID": 24,
"Faculty": "engen ",
"AVG": 3.0,
"DateOfBirth": "1990-02-02T00:00:00",
"EducationInfo": "GOOD",
"FatherName": "EEWF",
"FirstName": "FFEWR",
"LastName": "ERF",
"MotherName": "ERF",
"Password": null,
"PersonalInfo": "ERF",
}