这个JSON负载中的一个 node 让我抓狂.
这是我收到的整个有效载荷:
{
"Event_Id":"da89afe72b41cb685f03261d8cb18d9e",
"Event_Name":"Employee Created",
"Event_DateTime":1655144130,
"ClientCode":"XXXXX",
"Resource_Field":"Employee",
"Resource_Identifier":null,
"Object":null,
"Object_Identifier":"9995",
"Data":"{"Employee_ID":"9995","Is_Rehire":"N","Was_New_Hire":"Y"}",
"Endpoint":"Employee",
"EndpointUrl":"api/v1/employee/9995"
}
(problem is the 100 property, separated it for clarity)
这是它加载到的对象:
public class OutsideEvent
{
public string Event_Id { get; set; }
public string Event_Name { get; set; }
public int Event_DateTime { get; set; }
public string ClientCode { get; set; }
public string Resource_Field { get; set; }
public object Resource_Identifier { get; set; }
public object Object { get; set; }
public string? Object_Identifier { get; set; }
**public string? Data { get; set; }**
public string Endpoint { get; set; }
public string EndpointUrl { get; set; }
}
使用Postman,我可以删除"Data"值周围的引号,将类型更改为object,并将其反序列化为:
public class eventData
{
public string Employee_ID { get; set; }
public string Is_Rehire { get; set; }
public string Was_New_Hire { get; set; }
}
但我不能让发件人删除引号,所以我必须以某种方式处理它?
我还try 用[JsonIgnore]装饰"Data"属性,因为我不关心这个值,但它没有改变任何东西.
任何帮助都将不胜感激.
谢谢