gpt4 book ai didi

c# - 无法使用 Newtonsoft 反序列化 json

转载 作者:太空宇宙 更新时间:2023-11-03 20:56:04 25 4
gpt4 key购买 nike

我有这个 json:

   [
{
"id": "89",
"name": "Italy",
"link": "https://int.soccerway.com/national/italy/a100/?ICID=SN_02_89",
"iso": "IT"
}
]

我试图用 Newtonsoft.JSON 反序列化它,所以我创建了一个类模型:

public class Country
{
public string id { get; set; }
public string name { get; set; }
public string link { get; set; }
public string iso { get; set; }
}

和反序列化:

var json = JsonConvert.DeserializeObject<Country>(content);

content 包含上面的json,无论如何,这将返回:

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'SWP.Models.Country' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com