问题描述
我正在开发新的核心 5.0。
public static async Task<T> CallApiAsync<T>(string url,object body,HttpMethod method,string accesstoken = null,string accesstokenType = null)
{
HttpResponseMessage result = null;
string responseContent = null;
using (var httpClient = new HttpClient())
{
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method,url)
{
Content = new StringContent(JsonConvert.SerializeObject(body),Encoding.UTF8,"application/json")
};
AddHeader(accesstokenType,accesstoken,httpClient,httpRequestMessage);
result = await httpClient.SendAsync(httpRequestMessage);
responseContent = await result.Content.ReadAsstringAsync();
var settings = new JsonSerializerSettings() {
PreserveReferencesHandling = PreserveReferencesHandling.None,ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
return JsonConvert.DeserializeObject<T>(responseContent,settings);
}
}
然而我的回答是这样的:
{
"$id": "1","bills": {
"$id": "2","$values": [
{
"$id": "3","id": "FEw3Gcw38GVB","organizationId": "1"
},{
"$id": "3","id": "D16FbgYcXr35","organizationId": "2"
}
]
}
}
我的课是这样的:
public class BillsRoot {
[JsonProperty]
public List<Bill> bills { get; set; }
}
public class Bill {
[JsonProperty]
public string id { get; set; }
public string organizationId { get; set; }
}
如何防止 $id 和 $values?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)