[英]GraphQL dotnet Client response not deserializing
When deserializing into a dynamic I can get a response but when I try to deserialize into a typed object I get nothing back.当反序列化为动态时,我可以获得响应,但是当我尝试反序列化为类型化的 object 时,我什么也得不到。
Types being serialized被序列化的类型
public class User {
public string Forename { get; set; }
}
public class UserCollectionResponseType {
public List<User> Items { get; set; }
}
Request being made:提出要求:
var response = await graphQLHttpClient.SendQueryAsync<UserCollectionResponseType >(this.request).ConfigureAwait(false);
Sample response from API来自 API 的示例响应
{
"data": {
"users": {
"items": [
{
"forename": "4212hotp0i"
},
{
"forename": "XO - Test"
},
{
"forename": "5422q5htsd"
},
{
"forename": "XR - Test"
},
{
"forename": "2035snyyex"
},
{
"forename": "2379plsmri"
},
{
"forename": "7100e1igjl"
},
{
"forename": "94 - Test"
},
{
"forename": "ZX - Test"
},
{
"forename": "Test"
}
]
}
}
}
I was missing the Data
part of the Json when trying to deserialize into an object.尝试反序列化为 object 时,我丢失了 Json 的Data
部分。
My final objects looked like this:我的最终对象是这样的:
public partial class Data {
[JsonProperty("users")]
public Users Users { get; set; }
}
public partial class Users {
[JsonProperty("items")]
public Item[] Items { get; set; }
}
public partial class Item {
[JsonProperty("forename")]
public string Forename { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.