我已经设法让我在json的编码方面找到了我的位置,但是我不确定如何选择FetchTiming元素中的showtimes元素我有我的类构造,因此在json2csharp的帮助下特意列出了FetchTiming
public class MovieDetails
{
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public string image { get; set; }
public string secondry_images { get; set; }
public string actor { get; set; }
public string actoress { get; set; }
public string director { get; set; }
public string music_director { get; set; }
public string release_date { get; set; }
public string tags { get; set; }
public string age_restriction { get; set; }
public string box_office { get; set; }
public string official_site { get; set; }
public string duration { get; set; }
public string writers { get; set; }
public int imdb { get; set; }
public string status { get; set; }
public string language { get; set; }
public string created { get; set; }
public string modified { get; set; }
public string movie_category_id { get; set; }
public string slug { get; set; }
public string movie_show_time_id { get; set; }
public string theatre_movie_screen_id { get; set; }
public string videous { get; set; }
public string videos { get; set; }
public string comming_soon { get; set; }
public int avg { get; set; }
public string movie_details_url { get; set; }
}
public class FetchTiming
{
public string id { get; set; }
public string theater_name { get; set; }
public string address { get; set; }
public List<string> show_times { get; set; }
public string screen_id { get; set; }
public string title { get; set; }
}
public class MovieDetail
{
public MovieDetails movie_details { get; set; }
public List<FetchTiming> fetch_timing { get; set; }
}
}
Json Data
{&#34; movie_details&#34;:{&#34; id&#34;:&#34; 1&#34;,&#34; name&#34;:&#34; movie 1&#34; ,&#34;描述&#34;:&#34;电影1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ n \ r \ nmovie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ñ\ r \ n电影1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ n \ r \ n电影1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ n \ r \ n电影1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ n \ r \ n电影1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1movie 1 \ r \ N'#34;&#34;图像&#34;:&#34; HTTP://popcorn.pk/img/Movie/harley3.jpg",&#34; secondry_images&#34;:&#34;电影/ Jellyfish.jpg,电影/ Koala.jpg,电影/ Jellyfish.jpg&#34;&#34;演员&#34;:&#34;阿南丹&#34 ;, &#34; actoress&#34;:&#34;阿南丹&#34;&#34;导演&#34;:&#34;阿南丹&#34;&#34; music_director&#34;:&#34;阿南丹& #34;,&#34; release_date&#34;:&#34; 2015年3月18日&#34;,&#34;标签&#34;:&#34;电影1,电影1&#34;,&# 34; age_restriction&#34;:&#34; 14&#34;&#34; box_office&#34;:&#34; 36985214&#34;&#34; official_site&#34;:&#34; HTTP:/ /google.com",&#34; duration&#34;:&#34; 1.50小时&#34;,&#34;作家&#34;:&#34; anandan&#34;,&#34; imdb& #34;:8,&#34;状态&#34;:&#34; 1&#34;&#34;语言&#34;:&#34;泰米尔&#34;&#34;创建&#34; :&#34; 2015-03-11 05:11:31&#34;,#34;修改&#34;:&#34; 2015-03-25 10:12:39&#34;,&#34; movie_category_id&#34;:&#34;动作&#34;,&#34; slug&#34;:&#34;电影1&#34;,&#34; movie_show_time_id&#34;:&#34; 0&#34 ;,&#34; theatre_movie_screen_id&#34;:&#34; 0&#34;&#34; videous&#34;:&#34;&#34;&#34;视频&#34;:&#34 ;&#34;&#34; comming_soon&#34;:&#34; 0&#34;&#34;平均&#34;:0,&#34; movie_details_url&#34;:&#34; HTTP: //popcorn.pk/launch/Movies/view/1"},"fetch_timing":[{"id":"24"," ;在ater_name&#34;:&#34; SOZO WORLD CINEMA&#34;,&#34;地址&#34;:&#34;堡垒体育场,拉合尔 - 坎特,拉合尔,巴基斯坦&#34;,&#34; show_times&#34 ;:[&#34;下午5点&#34;],&#34; screen_id&#34;:&#34; 29&#34;,&#34;标题&#34;:&#34;标准屏幕&# 34;},{&#34; id&#34;:&#34; 25&#34;,&#34; theater_name&#34;:&#34; ATRIUM CINEMA&#34;,&#34;地址&#34; :&#34;中庭商场3楼,249 Staff Lines,Zaibunnisa Street,Saddar。巴基斯坦卡拉奇&#34;,&#34; show_times&#34;:[&#34; 2:00 pm&#34;],&#34; screen_id&#34;:&#34; 30&#34;,&# 34;标题&#34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 28&#34;,&#34; theater_name&#34;:&#34; CINEPAX - CITY AUDITORIUM&#34;,&#34;地址&#34;:&#34;位于Ayesha Manzil的Meezan Bank地区办事处对面,巴基斯坦卡拉奇的FB区块14区&#34;,&#34; show_times&#34; :[&#34;下午3:15&#34;,&#34;晚上8:45&#34;],&#34; screen_id&#34;:&#34; 33&#34;,&#34; title& #34;:&#34;标准画面&#34;},{&#34; id&#34;:&#34; 29&#34;,&#34; theatre_name&#34;:&#34; NUEPLEX&#34 ;,&#34;地址&#34;:&#34; The Place,Khayaban e Shaheen Phase 8,DHA&#34;,&#34; show_times&#34;:[&#34; 4:15 pm&#34 ;,&#34;上午11:30&#34;],&#34; screen_id&#34;:&#34; 34&#34;,&#34; title&#34;:&#34;标准屏幕&#34 ;},{&#34; id&#34;:&#34; 30&#34;,&#34; theater_name&#34;:&#34; CENTAURUS CINEPLEX&#34;,&#34;地址&#34;: &#34; Centaurus Mall,1 Jinnah Avenue,4楼Centaurus,F-8 Islamabad&#34;,&#34; show_times&#34;:[&#34; 10:45 pm&#34;,&#34; 11 :早上45点&#34;,&#34; 5:30下午&#34;],&#34; screen_id&#34;:&#34; 35&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;},{&#34; id& #34;:&#34; 32&#34;,&#34; theater_name&#34;:&#34; CINE MOOSH&#34;,&#34;地址&#34;:&#34; House no。 A / 18,Unit 3,主要的AutoBhan Road,Latifabad,Hyderabad&#34;,#34; show_times&#34;:[&#34; 12:00 pm&#34;,&#34; 11:15 pm& #34;,&#34; 6:15 pm&#34;],&#34; screen_id&#34;:&#34; 37&#34;,&#34; title&#34;:&#34;标准屏幕和#34;},{&#34; id&#34;:&#34; 33&#34;,&#34; theater_name&#34;:&#34; CINEGOLD PLEX&#34;,&#34;地址&#34 ;&#34;主要大道,花园城,在7期和7期之间; 8,Expressway,Rawalpindi 46000&#34;,&#34; show_times&#34;:[&#34; 12:15 pm&#34;],&#34; screen_id&#34;:&#34; 38&#34; ,&#34;标题&#34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 34&#34;,&#34; theater_name&#34;:& #34; CINEPAX JINNAH PARK&#34;,&#34;地址&#34;:&#34; Cinepax Jinnah Park Kachehri Road,Rawalpindi \ u00e2 \ u20ac \ u201c Pakistan&#34;,&#34; show_times&#34;: [&#34;下午3点&#34;,&#34;晚上10点30分&#34;,&#34;晚上8点&#34;,&#34;凌晨1点&#34;,& #34;下午5:30&#34;],&#34; screen_id&#34;:&#34; 39&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;}, {&#34; id&#34;:&#34; 35&#34;,&#34; theater_name&#34;:&#34; CINEPAX HOTEL ONE&#34;,&#34;地址&#34;:&# 34; Hotel One 99 / C,Peoples Colony(D D Ground)Faisalabad&#34;,&#34; show_times&#34;:[&#34; 3:00 pm&#34;,&#34; 8:15 pm& #34;,&#34; 1:45 am&#34;],&#34; screen_id&#34;:&#34; 40&#34;,&#34; title&#34;:&#34;标准屏幕和#34;},{&#34; id&#34;:&#34; 36&#34;,&#34; theater_name&#34;:&#34; SUPER CINEMA&#34;,&#34;地址&#34 ;:&#34; Vogue Tower,MM Alam road,Lahore&#34;,&#34; show_times&#34;: [&#34; 2:30 pm&#34;],&#34; screen_id&#34;:&#34; 41&#34;,&#34; title&#34;:&#34;标准屏幕&#34; },{&#34; id&#34;:&#34; 37&#34;,&#34; theater_name&#34;:&#34; SUPER CINEMA - SHABISTAN&#34;,&#34;地址&#34; :&#34; Shahbistan和Prince,Abbot road Lahore&#34;,&#34; show_times&#34;:[&#34; 1:00 pm&#34;,&#34; 4:00 pm&#34;, &#34;晚上8点&#34;],&#34; screen_id&#34;:&#34; 42&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;} ,{&#34; id&#34;:&#34; 38&#34;,&#34; theater_name&#34;:&#34; CINE STAR&#34;,&#34;地址&#34;:&# 34;情节#13,2市民中心乡镇拉合尔&#34;,&#34; show_times&#34;:[&#34; 1:00 am&#34;,&#34; 7:30 pm&#34;], &#34; screen_id&#34;:&#34; 43&#34;,&#34; title&#34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&# 34; 39&#34;,&#34; theater_name&#34;:&#34; TAJ CINEMA&#34;,&#34;地址&#34;:&#34;剧情#13,2市民中心城镇拉合尔&#34 ;,&#34; show_times&#34;:[&#34; 2:30 pm&#34;,&#34; 8:00 pm&#34;],&#34; screen_id&#34;:&#34; 44&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 40&#34;,&#34; theater_name&# 34 ;: &#34; CINESTAR IMAX&#34;,&#34;地址&#34;:&#34;情节#13,2市民中心乡镇拉合尔&#34;,&#34; show_times&#34;:[&#34;下午2:00&#34;,&#34;晚上7:30&#34;],&#34; screen_id&#34;:&#34; 45&#34;,&#34;标题&#34;:&# 34;标准屏幕&#34;},{&#34; id&#34;:&#34; 41&#34;,&#34; theater_name&#34;:&#34; Taj Mahal Multiplex&#34;,&# 34;地址&#34;:&#34; Taj Mahal Multiplex Cinemas,Railway Road,Faisalabad-38000&#34;,&#34; show_times&#34;:[&#34; 4:00 pm&#34;,&# 34;晚上10点&#34;,&#34;晚上7点&#34;],&#34; screen_id&#34;:&#34; 46&#34;,&#34;标题&#34;: &#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 44&#34;,&#34; theater_name&#34;:&#34; DHA Cinema&#34;,& #34;地址&#34;:&#34; 305-R Block,DHA,Lahore Pakistan&#34;,&#34; show_times&#34;:[&#34; 1:00 am&#34;,&#34 ;下午7:30&#34;],&#34; screen_id&#34;:&#34; 49&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;},{& #34; id&#34;:&#34; 47&#34;,&#34; theater_name&#34;:&#34; Imperial Cinemas&#34;,&#34;地址&#34;:&#34; Imperial Garden Homes,Lahore,Pakistan&#34;,&#34; show_times&#34;:[&#34; 12:50 am& #34;,&#34; 2:30 pm&#34;,&#34; 7:45 pm&#34;],&#34; screen_id&#34;:&#34; 52&#34;,&#34标题&#34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 48&#34;,&#34; theater_name&#34;:&#34; CINEPAX GUJRANWALA&#34;,&#34;地址&#34;:&#34; Prince Cinepax Main GT Road,Gujranwala - Pakistan&#34;,&#34; show_times&#34;:[&#34; 12:45 pm&# 34;,&#34; 3:15 pm&#34;,&#34; 3:30 pm&#34;,&#34; 11:00 pm&#34;,&#34; 8:30 pm&#34; ,&#34;下午12:30&#34;,&#34;下午6:00&#34;],&#34; screen_id&#34;:&#34; 53&#34;,&#34;标题&# 34;:&#34;标准屏幕&#34;},{&#34; id&#34;:&#34; 49&#34;,&#34; theater_name&#34;:&#34; Super Cinema - Gujrat& #34;,&#34;地址&#34;:&#34; Super Cinema Gujrat,Gt Road,Gujrat&#34;,&#34; show_times&#34;:[&#34; 1:00 pm&#34; ,&#34;晚上7点&#34;],&#34; screen_id&#34;:&#34; 54&#34;,&#34;标题&#34;:&#34;标准屏幕&#34; },{&#34; id&#34;:&#34; 51&#34;,&#34; theater_name&#34;:&#34; Capri Cinema&#34;,&#34;地址&#34;:& #34; Gazdarabad,巴基斯坦卡拉奇,巴基斯坦卡拉奇&#34;,#34; show_times&#34;:[&#34; 3:00 pm&#34;,&#34; 9:00 pm&#34;, &#34;下午6:00&#34;],&#34; screen_id&#34;:&#34; 56&#34;,&#34;标题&#34;:&#34;标准屏幕&#34;}]}
我如何呼唤网络服务 private async Task WCFRESTServiceCall(string methodRequestType,string methodName,string bodyParam =&#34;&#34;)
{
try {
string ServiceURI = "/app/webroot/launchwebservice/index.php/webservice/" + methodName;
HttpClient httpClient = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(methodRequestType == "GET" ? HttpMethod.Get : HttpMethod.Post, ServiceURI);
if (!string.IsNullOrEmpty(bodyParam))
{
request.Content = new StringContent(bodyParam, Encoding.UTF8, "application/json");
}
HttpResponseMessage response = await httpClient.SendAsync(request);
string jsongString = await response.Content.ReadAsStringAsync();
return jsongString;
}
catch(Exception ex)
{
return ""; }
}
}
然后我调用该方法,因此引用了我认为足够的fetching_time对象,但它返回的null用于获取时间。
public async Task<FetchTiming> GetMovieShowtimesAsync()
{
string jsonresult = await WCFRESTServiceCall("GET", "movie_details");
var jarray = JsonConvert.DeserializeObject<FetchTiming>(jsonresult);
return jarray;
}
编辑完成
好的我已经完成了他的建议,现在我显示如下,但现在只是显示任何想法我做错了我应该说{绑定Fetching_Time而不是?
private async void listViewShowtimes_Loaded(object sender, RoutedEventArgs e)
{
popcornpk_Dal _dal = new popcornpk_Dal();
MovieDetail _showTimes = await _dal.GetMovieShowtimesAsync();
var listView = (ListView)sender;
listView.ItemsSource = _showTimes.fetch_timing;
}
修改2
我应该已经解释过我已经有了这就是为什么我得到错误obv
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListView x:Name="listViewShowtimes" ItemsSource="{Binding}" Loaded="listViewShowtimes_Loaded">
<DataTemplate>
<StackPanel Height="505">
<TextBlock FontSize="13" x:Name="txtshowtime" Text="{Binding theater_name}" HorizontalAlignment="Left" Margin="19,223,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="212" Foreground="White" Height="29" SelectionChanged="txtTtile_SelectionChanged"/>
<TextBlock FontSize="13" x:Name="txtshow_times" Text="{Binding show_times}" HorizontalAlignment="Left" Margin="19,223,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="212" Foreground="White" Height="29" SelectionChanged="txtTtile_SelectionChanged"/>
</StackPanel>
</DataTemplate>
</ListView>
</Grid>
下方的列表中显示节目时间
答案 0 :(得分:0)
您调用的服务会返回整个MovieDetail
类,但您尝试将其反序列化为FetchTiming
类。
只需将字符串反序列化为MovieDetail
类,然后从中获取时序数组。