Csharp/C#教程:使用JSON.NET从JSON获取价值分享


使用JSON.NET从JSON获取价值

我尝试使用https://www.codeplex.com/Json从json对象中提取值。

我使用imdbapi.com,他们像这样返回json:

{"Title": "Star Wars", "Year": "1977", "Rated", "PG", "Released", "25 May 1977", "Genre", "Action, Adventure, Fantasy, Sci-Fi "" Director ":" George Lucas "," Writer "," George Lucas "," Actors ":" Mark Hamill, Harrison Ford, Carrie Fisher, Alec Guinness, "" Plot ":" Luke Skywalker leaves his home planet, teams up With Other Rebels, and Tries to save Princess Leia from the evil clutch of Darth hrs 1 min "," Rating ":" 8.8 "," Votes ":" 397318 "," ID ":" tt0076759 "," Response ":" True "} 

我如何获得这样的头衔,评级,年份? 并将其保存到我的对象?

这行返回正确的json:

 JObject jObject = JObject.Parse (json); 

现在我只需要帮助挑选出我想要的数据。 有什么建议?

这应该可以帮助你https://james.newtonking.com/pages/json-net.aspx

 string json = @"{ ""Name"": ""Apple"", ""Expiry"": new Date(1230422400000), ""Price"": 3.99, ""Sizes"": [ ""Small"", ""Medium"", ""Large"" ] }"; JObject o = JObject.Parse(json); //This will be "Apple" string name = (string)o["Name"]; 

JObject API文档

我相信你对返回JTokens的.Item [key]集合很感兴趣。

完整文档

上述就是C#学习教程:使用JSON.NET从JSON获取价值分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1016974.html

(0)
上一篇 2021年12月31日
下一篇 2021年12月31日

精彩推荐