JsonResult返回空Json

Qui*_*ver 1 .net c# asp.net-mvc json

我的控制器中有以下JsonResult:

public JsonResult SearchRxNormDrugs(string term)
{
    var matches = rxnConsoService.SearchRxNormDrugs(term);

    return Json(matches, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)

在调试项目时,我可以看到它matches有300多个结果.所有比赛都有内容.但是,当我在url中导航到此操作时,我得到的结果如下:

(点击图片查看完整尺寸) 在此输入图像描述

模型:

public class RxNConso
{
    [KeyProperty(Identity = true)]
    string RXCUI { get; set; }
    string LAT { get; set; }
    string TS { get; set; }
    string LUI { get; set; }
    string STT { get; set; }
    string SUI { get; set; }
    string ISPREF { get; set; }
    string RXAUI { get; set; }
    string SAUI { get; set; }
    string SCUI { get; set; }
    string SDUI { get; set; }
    string SAB { get; set; }
    string TTY { get; set; }
    string CODE { get; set; }
    string STR { get; set; }
    string SRL { get; set; }
    string SUPPRESS { get; set; }
    string CVF { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

matchesIEnumerableRxNConso

IEnumerable<RxNConso> matches
Run Code Online (Sandbox Code Playgroud)

是什么导致这个?

Rob*_*Rob 5

大多数序列化库仅关注可公开访问的属性/字段.您的类可能只有私有字段/属性,这可以解释为什么您可以在调试器中查看值,但在序列化时获得空结果.

  • 在我的帖子中添加更多信息后,我意识到我的"模型"中的属性未公开.这解决了这个问题,谢谢! (2认同)