コントローラーに次のコードがあります。
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public DateTime Birthday { get; set; }
}
public ActionResult JsonObject()
{
Person[] persons = new Person[]{
new Person{Name="John", Age=26, Birthday=new DateTime(1986,1,1)},
new Person{Name="Tom", Age=10, Birthday=new DateTime(2002, 1, 9)}
};
return Json(persons, JsonRequestBehavior.AllowGet);
}
通常、次のような結果が得られます:[{"Name": "John"、 "Age":26、 "Birthday": "/ Date(504892800000)/"}、{"Name": "Tom"、 "Age ":10、"誕生日 ":" / Date(1010505600000)/ "}]
それは大丈夫です、しかし、私はユーザーのために誕生日を表示しないというオプションを作りたいです。したがって、期待される結果は次のようになります。[{"Name": "John"、 "Age":26}、{"Name": "Tom"、 "Age":10}]
誕生日プロパティをJSONにシリアル化しないようにするにはどうすればよいですか?