responsestring = await response.Content.ReadAsStringAsync();
ClassifierResponse Response = JsonConvert.DeserializeObject<ClassifierResponse>(responsestring); 我的回答是
{
"resultList": [
{
"modelId": 11,
"modelName": "indves12",
"modelLang": "US",
"modelVersion": 5,
"scoreMap": {
"individual": 0.401956,
"vessel": 0.598043
},
"bestCategory": "vessel"
}
]
} 而im获取此错误: Newtonsoft.Json.JsonSerializationException:‘无法将当前JSON对象反序列化为类型JSON (例如,{“名称”:“值”}),因为该类型需要一个JSON数组(例如,1,2,3)才能正确反序列化。要修复此错误,要么将JSON更改为JSON数组(例如,1,2,3),要么更改反序列化类型,使之成为可以从JSON对象反序列化的普通.NET类型(例如,不像整数这样的原始类型,而不是数组或列表之类的集合类型)。还可以将JsonObjectAttribute添加到类型中,以强制它从JSON对象反序列化。
发布于 2021-06-03 15:21:04
试试这门课
public class ClassifierResponse
{
public List<ResultList> ResultList { get; set; }
}
public class ResultList
{
public int ModelId {get; set;}
public string ModelName { get; set; }
public string ModelLang { get; set; }
public int ModelVersion { get; set; }
public Scoremap Scoremap { get; set;}
public string BestCategory { get; set; }
}
public class Scoremap
{
public double Individual{ get; set; }
public double Vessel { get; set; }
}https://stackoverflow.com/questions/67823742
复制相似问题