休息api收到复杂的json

问题描述 投票:0回答:1

我被卡住了。 我传递一个简单的json对象,它工作正常。但我让它变得更复杂一些。在这种情况下,我的消息对象中的fileInfo对象我遇到了麻烦。收到文件信息时为空。我知道我必须忽略一些简单的事情。这是我传递的json对象的示例。

提前致谢。

enter image description here

public class ContactUsInformation
{
    public string name { get; set; }
    public string company { get; set; }
    public string email { get; set; }
    public string phone { get; set; }
    public string description { get; set; }
    public IList<AttachmentInfo> fileInfo{ get; set; }
    //public AttachmentInfo[] fileInfo { get; set; }
    /*public string[] fileName { get; set; }
    public string[] fileType{ get; set; }
    public string[] fileValue { get; set; }*/
}
public class AttachmentInfo{
    public string fileName { get; set; }
    public string fileType { get; set; }
    public string fileValue { get; set; }
}

public IEnumerable Contact([FromBody] ContactUsInformation [] contactUsInformation)

enter image description here

c# angular rest
1个回答
2
投票
  • 在JavaScript方面,我看到fileInfo带有字符串值。它是否正确?
  • 在JavaScript中,您使用JSON.stringify设置fileInfo吗?如果是这样只是使用该对象,那么它将正确序列化(希望)
© www.soinside.com 2019 - 2024. All rights reserved.