У меня есть следующий метод:
[HttpPost]
[AjaxOnly]
public JsonResult ValidateInput(string text)
{
return new EmptyJsonResult();
}
/// <summary>
/// returns a JSON result that is marked as being empty.
/// </summary>
public sealed class EmptyJsonResult : JsonResult
{
public EmptyJsonResult()
{
Data = new JsonResultData
{
Empty = true
};
}
}
public class JsonResultData
{
public bool Empty { get; set; }
public string[] Errors { get; set; }
}
Я ожидал, что это вернет браузер {"Empty":true}
, но вместо этого он вернет {"Empty":true,"Errors":null}
.
Есть ли какой-либо атрибут или что-то, что я могу установить, чтобы избежать возврата нулей на объекты, которые я не заполнял?