【问题标题】:restapi receive complex jsonrest api 接收复杂的json
【发布时间】:2019-02-22 14:47:05
【问题描述】:

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

提前致谢。

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)

【问题讨论】:

    标签: c# angular rest


    【解决方案1】:
    • 在 JavaScript 方面,我看到 fileInfo 带有一个字符串值。这是正确的吗?
    • 在 JavaScript 中,您是否使用 JSON.stringify 设置 fileInfo?如果是这样,只需使用该对象,那么它将正确序列化(希望如此)

    【讨论】:

    • 从未注意到双引号。我会检查这是否是问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    • 2013-07-24
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2016-10-12
    相关资源
    最近更新 更多