gpt4 book ai didi

c# - JsonResult 返回空 Json

转载 作者:太空宇宙 更新时间:2023-11-03 19:54:53 25 4
gpt4 key购买 nike

我的 Controller 中有以下 JsonResult:

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

return Json(matches, JsonRequestBehavior.AllowGet);
}

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

(点击图片查看大图) enter image description here

型号:

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; }
}

matchesRxNConso

IEnumerable
IEnumerable<RxNConso> matches

知道是什么原因造成的吗?

最佳答案

大多数序列化库只关心可公开访问的属性/字段。您的类很可能只有私有(private)字段/属性,这可以解释为什么您可以在调试器中看到值,但在序列化时得到空结果。

关于c# - JsonResult 返回空 Json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34815402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com