如何用参数中的“0”反序列化json body

How to deserialize json body with "0" in parameter

我正在使用一个 API 给我这个 json 作为回应, 这是 json 响应 body :

{
   "meta":{
      "status":200,
      "message":"success"
   },
   "data":{
      "0":{
         "MsgID":"2661689817",
         "Status":"6",
         "SendTime":"2021-10-3114:30:04",
         "DeliverTime":"2021-10-31 14:30:07"
      }
   }
}

我的问题是 "0":{... 这个 body。

如何将其反序列化为 Class。

无法反序列化 "string _0" prop.

正如@TheGeneral 所说,这就像一本字典。您可以解析 - 像这样:

public void ParseObject()
{
    var response = @"{
                       'meta':{
                          'status':200,
                          'message':'success'
                       },
                       'data':{
                          '0':{
                             'MsgID':'2661689817',
                             'Status':'6',
                             'SendTime':'2021-10-3114:30:04',
                             'DeliverTime':'2021-10-31 14:30:07'
                          }
                       }
                    }";

    var responseObj = JsonConvert.DeserializeObject<MetaData>(response);
}

public class MetaData
{
    public Meta Meta { get; set; }
    public Dictionary<int, Data> Data { get; set; }
}

public class Meta
{
    public string Status { get; set; }
    public string Message { get; set; }
}

public class Data
{
    public string MsgId { get; set; }
    public string Status { get; set; }
    public string SendTime { get; set; }
}

尝试使用 JsonProperty

public class Data
{
    [JsonProperty("0") ]
    public _0 _0 { get; set; }
}

public class _0
{
    public string MsgID { get; set; }
    public string Status { get; set; }
    public string SendTime { get; set; }
    public string DeliverTime { get; set; }
}