无法使用WebAPI反序列化整数数组?

时间:2013-06-10 00:30:16

标签: json asp.net-web-api json.net

我发送以下内容:

{
    "setIds": ["1", "2"],
    "folderIds": ["3", "4"],
    "filter": "FILTERED"
};

到接受SessionDto的API端点:

[DataContract]
public class SessionDto
{

    [DataMember(EmitDefaultValue = true)]
    public Array FolderIds { get; set; }

    [DataMember(EmitDefaultValue = true)]
    public Array SetIds { get; set; }

    [DataMember(IsRequired = true)]
    public string Filter { get; set; }

}

SetIds和FolderIds总是为空;过滤器来得很好。我正在使用newtonsoft.json.serialization。知道为什么这不起作用,或者我如何进一步调试?

1 个答案:

答案 0 :(得分:2)

[DataMember(EmitDefaultValue = true)]
    public int[] FolderIds { get; set; }

    [DataMember(EmitDefaultValue = true)]
    public int[] SetIds { get; set; }

    [DataMember(IsRequired = true)]
    public string Filter { get; set; }

尝试int数组