【发布时间】:2020-01-30 03:06:47
【问题描述】:
我的 JSON 响应如下所示,
[
{
"faceRectangle": {
"top": 214,
"left": 472,
"width": 450,
"height": 450
},
"faceAttributes": {
"age": 19.0,
"emotion": {
"anger": 0.0,
"contempt": 0.0,
"disgust": 0.0,
"fear": 0.0,
"happiness": 0.0,
"neutral": 0.996,
"sadness": 0.003,
"surprise": 0.001
}
}
}
]
我的 C# 类如下:
public class Output
{
public List<FaceRectangle> FaceRectangles { get; set; }
public List<FaceAttribute> faceAttributes { get; set; }
}
public class FaceAttribute
{
public List<Emotion> Emotions { get; set; }
public int age { get; set; }
}
public class Emotion {
public float anger { get; set; }
public float contempt { get; set; }
public float disgust { get; set; }
public float fear { get; set; }
public float happiness { get; set; }
public float neutral { get; set; }
public float sadness { get; set; }
public float surprise { get; set; }
}
public class FaceRectangle
{
public int top { get; set; }
public int left { get; set; }
public int width { get; set; }
public int height { get; set; }
}
但是,当我尝试反序列化上述响应时,我收到以下错误。 错误代码显示为“不支持数组的反序列化” enter image description here
谁能帮我解决这个问题? 谢谢!
【问题讨论】:
-
你能记录 format.GetType() 吗?
标签: c# json azure deserialization