简体   繁体   English

从json中为Windows Phone 7检索数据

[英]retrieving data from json for windows phone 7

我打算创建一个Windows应用程序(C#),以显示最近发行的电影的名称。我具有以json格式显示数据的url。我只想检索电影的名称和发行日期。从Google搜索i知道我必须创建一个类,但我不知道该如何开始..我是一只新蜜蜂,请指导我,以及我当前正在使用7.1所需的Os版本。以下是我必须从中获取的json检索数据

{"total":47,"movies":[{"id":"771242005","title":"Magic Mike","year":2012,"mpaa_rating":"R","runtime":110,"critics_consensus":"Magic Mike's sensitive direction, smart screenplay, and strong performances allows audiences to have their beefcake and eat it too.","release_dates":{"theater":"2012-06-29","dvd":"2012-10-23"},"ratings":{"critics_rating":"Certified Fresh","critics_score":79,"audience_rating":"Upright","audience_score":63},"synopsis":"Set in the world of male strippers, Magic Mike is directed by Steven Soderbergh and stars Channing Tatum in a story inspired by his real life. The film follows Mike (Tatum) as he takes a young dancer called The Kid (Pettyfer) under his wing and schools him in the fine arts of partying, picking up women, and making easy money. -- (C) Warner Bros.","posters":{"thumbnail":"http://content8.flixster.com/movie/11/16/66/11166610_mob.jpg","profile":"http://content8.flixster.com/movie/11/16/66/11166610_pro.jpg","detailed":"http://content8.flixster.com/movie/11/16/66/11166610_det.jpg","original":"http://content8.flixster.com/movie/11/16/66/11166610_ori.jpg"},"abridged_cast":[{"name":"Channing Tatum","id":"162661835","characters":["Magic Mike"]},{"name":"Alex Pettyfer","id":"326298019","characters":["Adam","The Kid"]},{"name":"Matt Bomer","id":"771077752","characters":["Ken"]},{"name":"Joe Manganiello","id":"770800475","characters":["Big Dick Richie"]},{"name":"Matthew McConaughey","id":"162652350","characters":["Dallas"]}],"alternate_ids":{"imdb":"1915581"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771242005.json","alternate":"http://www.rottentomatoes.com/m/magic_mike/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771242005/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771242005/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771242005/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771242005/similar.json"}}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/lists/dvds/upcoming.json?page_limit=1&country=us&page=1","next":"http://api.rottentomatoes.com/api/public/v1.0/lists/dvds/upcoming.json?page_limit=1&country=us&page=2","alternate":"http://www.rottentomatoes.com/dvd/upcoming.json"},"link_template":"http://api.rottentomatoes.com/api/public/v1.0/lists/dvds/upcoming.json?page_limit={results-per-page}&page={page-number}&country={country-code}"}

You could try JSON.NET: http://json.codeplex.com/ 您可以尝试JSON.NET: http://json.codeplex.com/

Note: I had to truncate the JSON string so the formatter here could handle it. 注意:我必须截断JSON字符串,以便此处的格式化程序可以处理它。

String JSONStr = @"{""total"":47,""movies"":[{""id"":""771242005"",""title"":""Magic....";

JObject jObject = JObject.Parse(JSONStr);

// movies is an array....of one.
Array Movies = jObject["movies"].ToArray();

foreach (JToken Movie in Movies)
    Response.Write(Movie["title"].ToString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM