我得到了这个JSON字符串,它有什么问题?我可以通过几个在线JSON测试人员运行它们,他们都说OK。但是,当这通过实体框架发布到我的c#web api时,我的帖子正文为空。有任何想法吗? 这是POST功能:JSON字符串无效,无法发布到c#web api?
public void Post([FromBody]List<AIM.RunningProcess> list_runningprocesses)
{
if (list_runningprocesses == null) return;
这是JSON字符串:
[
{
"PSComputerName": "eetpcx31v.admin.eetp.local",
"ProcessName": "AcroRd32.exe",
"ProcessID": 14240,
"CommandLine": ".C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe. .C:\\Users\\jmetzler\\AppData\\Local\\Microsoft\\Windows\\Temporary Internet Files\\Content.Outlook\\VG2QRLL8\\Pöyry_RevealingFlexibilityValueStudy_Proposal_v2_0.pdf.",
"CreationDate": "Oct 24 2013 14:21:09",
"Username": "jmetzler",
"RemoteIP": null
}
]
显然它失败,因为命令行属性。 'commandline'的数据库列属性是varchar(8000)。这是'RunningProcess'类。
public partial class RunningProcess
{
public string PSComputerName { get; set; }
public string ProcessName { get; set; }
public string ProcessID { get; set; }
public string CommandLine { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
public string Username { get; set; }
public string RemoteIP { get; set; }
}
任何人有什么想法?
'JsonConvert.DeserializeObject <名单>(JSON)'对我的作品(其中'json'是你的JSON字符串) 。你为什么说“显然由于CommandLine属性而失败”?我没有看到任何明显的错误。 –
'ProcessID'可能是一个'int'(它是JSON中的一个数字),否则你的类对我来说看起来很好,就像JSON一样。 –