从webhook c#检索JSON数组集合返回

时间:2017-10-16 13:42:37

标签: c# json asp.net-web-api2

我的webAPI端点收到了以下JSON。

{"time":1507739203,"messages":{"closedChat":[{"id":1280091,"channel":"widget","closed_at":"2017-10-11 13:26:43","tabulation":false}]},"token":"5df3c296972ffa6972"}

我能够得到#34;时间"在我的控制器中变量,但我无法得到" closedChat"集合,总是返回null。

这是我的控制器:

[AllowAnonymous]
[Route("api/test1/closedChat")]
[HttpPost]
public string closedChat([FromBody] rag msg)
{
    string messageTime = msg.time; //this works
    List<Fimmsg> teste2 = msg.messages; //this do not

    return messageTime;
}

这是我创建的rag类,用于接收JSON返回:

public class rag
    {
        [JsonProperty("time")]
        public string time { get; set; } //this works

        [JsonProperty("messages")]
        public List<Fimmsg> messages { get; set; } //this do not

    }

我创建了一个Fimmsg类来保存&#34;消息&#34;阵列/列表:

public class Fimmsg
{
        public int id { get; set; }
        public string channel { get; set; }
        public string closed { get; set; }
        public string tabulation { get; set; }
}

我错过了什么才能获得关闭&#39;集合?

0 个答案:

没有答案