// 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 回答
- 0 關注
- 296 瀏覽
添加回答
舉報
0/150
提交
取消