我已经坚持了一段时间。我有一个JSON响应,向我发送包含句点的密钥。例如:“ cost_center.code”
如何将其放入对象?我没有收到任何错误,但该值只是作为null传入,并且未反序列化到我的班级中。
这是我的课程:
public class Result
{
public string company { get; set; }
public string first_name { get; set; }
public string email { get; set; }
public string employee_id { get; set; }
public string last_name { get; set; }
[DeserializeAs(Name="cost_center.code")]
public string cost_center { get; set; }
}
public class RootObject
{
public List<Result> result { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是JSON响应:
{
"result": [
{
"company": "My Company",
"first_name": "First",
"email": "example@fakeaddress.com",
"employee_id": "123456789",
"last_name": "Last", …Run Code Online (Sandbox Code Playgroud)