c# - How Serialize single value by json.net? -
i serializing student
class using json.net
.
i add serialized object attribute (called cheak
not member of student
class.
this class student:
public class student { public int id { get; set; } [jsonignore] public faculty faculty { get; set; } [jsonproperty("faculty")] public string facultyname { { 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", }
i want add attribute "cheak" serialized object:
{ **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", }
if need able deserialize serialize object inherit student onto new class this
public class studentjson : student { public bool cheak { get; set; } }
you can pass serialized.
Comments
Post a Comment