Asp.net MVC JSON操作返回bool

Asp.net MVC JSON操作返回bool,asp.net,jquery,asp.net-mvc,json,Asp.net,Jquery,Asp.net Mvc,Json,我的ASP.NET MVC操作是这样写的: // // GET: /TaxStatements/CalculateTax/{prettyId} public ActionResult CalculateTax(int prettyId) { if (prettyId == 0) return Json(true, JsonRequestBehavior.AllowGet); TaxStatement sel

我的ASP.NET MVC操作是这样写的:

    //
    // GET: /TaxStatements/CalculateTax/{prettyId}
    public ActionResult CalculateTax(int prettyId)
    {
        if (prettyId == 0)
            return Json(true, JsonRequestBehavior.AllowGet);

        TaxStatement selected = _repository.Load(prettyId);
        return Json(selected.calculateTax, JsonRequestBehavior.AllowGet); // calculateTax is of type bool
    }
我对此有问题,因为在jquery函数中使用它时,我遇到了各种各样的错误,主要是
toLowerCase()
函数失败

所以我不得不改变操作,让它们以字符串的形式返回bool(对bool值调用
ToString()
),这样就可以返回
true
false
(在qoutes中),但我有点不喜欢它


其他人如何处理这种情况?

我会使用匿名对象(记住JSON是一个键/值对):

然后:

success: function(result) {
    if (result.isCalculateTax) {
        ...
    }
}
备注:如果
selected.calculateTax
属性为布尔值,.NET命名约定为将其称为
IsCalculateTax

success: function(result) {
    if (result.isCalculateTax) {
        ...
    }
}