// Get the JSON response. string contentString = await response.Content.ReadAsStringAsync(); Console.WriteLine(contentString); var rs = Newtonsoft.Json.Linq.JToken.Parse(contentString); Result rst = JsonConvert.DeserializeObject<Result>(contentString);//Here i need to get the first value in the description as it appears to be a listvar firstValue= rst.description;//And also a value from captionvar captionValue = rst.Caption public class Result { public Category[] categories { get; set; } public Description description { get; set; } public string requestId { get; set; } public Caption caption { get; set;} public Metadata metadata { get; set; } public Color color { get; set; } } public class Description { public string[] tags { get; set; } public Caption[] captions { get; set; } } public class Caption { public string text { get; set; } public float confidence { get; set; } } public class Metadata { public int width { get; set; } public int height { get; set; } public string format { get; set; } } public class Color { public string dominantColorForeground { get; set; } public string dominantColorBackground { get; set; } public string[] dominantColors { get; set; } public string accentColor { get; set; } public bool isBWImg { get; set; } } public class Category { public string name { get; set; } public float score { get; set; } }} 我明白我想要的很简单,但对我来说看起来有点复杂。我已经使用了Result //rst = JsonConvert.DeserializeObject<Result>(contentString);连接并获取响应,我已经传入了 JSON 数据的 contentString。我只想得到我想要的价值。使用 description 作为示例会更有帮助。谢谢
3 回答
- 3 回答
- 0 关注
- 267 浏览
添加回答
举报
0/150
提交
取消