このJSONデータを含むURLがあります:
[{"title":"Snow White & the Huntsman","year":2012,"released":1338534000,"url":"http://localhost/movie/snow-white-and-the-huntsman-2012","trailer":"http://youtube.com/watch?v=11Wn-_uyT48","runtime":127,"tagline":"","overview":"After the Evil Queen marries the King, she performs a violent coup in which the King is murdered and his daughter, Snow White, is taken captive. Almost a decade later, a grown Snow White is still in the clutches of the Queen. In order to obtain immortality, The Evil Queen needs the heart of Snow White. After Snow escapes the castle, the Queen sends the Huntsman to find her in the Dark Forest.","certification":"PG-13","imdb_id":"tt1735898","tmdb_id":"58595","poster":"http://trakt.us/images/posters_movies/180748.1.jpg","images":{"poster":"http://trakt.us/images/posters_movies/180748.1.jpg","fanart":"http://trakt.us/images/fanart_movies/180748.1.jpg"},"watchers":15,"ratings":{"percentage":68,"votes":105,"loved":71,"hated":34},"genres":["Adventure","Fantasy","Action","Drama"]}
これを解析してメトロアプリに表示しようとしていますが、私の人生で機能させることができません!私はこのような多くのことを試みました:
string trendingURL = "http://Localhost/movies/trending.json/";
MovieDetails newMovie = new MovieDetails();
newMovie.title = "";
newMovie.cover = "";
//DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(MovieDetails));
//StreamReader sr = new Stream(trendingURL);
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(trendingURL);
var str = await response.Content.ReadAsStreamAsync();
var ser = new DataContractJsonSerializer(typeof(MovieDetails));
var collection = (MovieDetails)ser.ReadObject(str);
var results = collection.title;