首页 新闻 搜索 专区 学院

请问12306的这段json怎么解析

0
悬赏园豆:100 [已解决问题] 解决于 2014-01-14 23:13

数据:
{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":[{"queryLeftNewDTO":{"train_no":"65000K122405","station_train_code":"K1224","start_station_telecode":"GGQ","start_station_name":"广州东","end_station_telecode":"CDW","end_station_name":"成都","from_station_telecode":"GGQ","from_station_name":"广州东","to_station_telecode":"NJW","to_station_name":"内江","start_time":"17:42","arrive_time":"06:06","day_difference":"2","train_class_name":"","lishi":"36:24","canWebBuy":"N","lishiValue":"2184","yp_info":"1024303000406840000010243000003042900000","control_train_day":"20991231","start_train_date":"20140124","seat_feature":"W3431333","yp_ex":"10401030","train_seat_feature":"3","seat_types":"1413","location_code":"Q6","from_station_no":"01","to_station_no":"25","control_day":19,"sale_time":"1330","is_support_card":"0","gg_num":"--","gr_num":"--","qt_num":"--","rw_num":"无","rz_num":"--","tz_num":"--","wz_num":"无","yb_num":"--","yw_num":"无","yz_num":"无","ze_num":"--","zy_num":"--","swz_num":"--"},"secretStr":"","buttonTextInfo":"预订"},{"queryLeftNewDTO":{"train_no":"630000K82708","station_train_code":"K827","start_station_telecode":"GZQ","start_station_name":"广州","end_station_telecode":"ICW","end_station_name":"成都东","from_station_telecode":"GZQ","from_station_name":"广州","to_station_telecode":"NJW","to_station_name":"内江","start_time":"19:22","arrive_time":"06:40","day_difference":"2","train_class_name":"","lishi":"35:18","canWebBuy":"N","lishiValue":"2118","yp_info":"1024303000406840000010243000003042900000","control_train_day":"20991231","start_train_date":"20140124","seat_feature":"W3431333","yp_ex":"10401030","train_seat_feature":"3","seat_types":"1413","location_code":"Q7","from_station_no":"01","to_station_no":"26","control_day":19,"sale_time":"1200","is_support_card":"0","gg_num":"--","gr_num":"--","qt_num":"--","rw_num":"无","rz_num":"--","tz_num":"--","wz_num":"无","yb_num":"--","yw_num":"无","yz_num":"无","ze_num":"--","zy_num":"--","swz_num":"--"},"secretStr":"","buttonTextInfo":"预订"}],"messages":[],"validateMessages":{}}

 

实体类

Public Class TicketJson
    Public validateMessagesShowId As String
    Public status As String
    Public httpstatus As String
    Public data() As TicketJsonData
    Public messages As TicketJsonMessages
    Public validateMessages As String
End Class

Public Class TicketJsonData
    Public queryLeftNewDTO() As TicketJsonQueryLeftNewDTO
    Public secretStr As String
    Public buttonTextInfo As String
End Class

Public Class TicketJsonQueryLeftNewDTO
    Public train_no As String
    Public station_train_code As String
    Public start_station_telecode As String
    Public start_station_name As String
    Public end_station_telecode As String
    Public end_station_name As String
    Public from_station_telecode As String
    Public from_station_name As String
    Public to_station_telecode As String
    Public to_station_name As String
    Public start_time As String
    Public arrive_time As String
    Public day_difference As String
    Public train_class_name As String
    Public lishi As String
    Public canWebBuy As String
    Public lishiValue As String
    Public yp_info As String
    Public control_train_day As String
    Public start_train_date As String
    Public seat_feature As String
    Public yp_ex As String
    Public train_seat_feature As String
    Public seat_types As String
    Public location_code As String
    Public from_station_no As String
    Public to_station_no As String
    Public control_day As String
    Public sale_time As String
    Public is_support_card As String
    Public gg_num As String
    Public gr_num As String
    Public qt_num As String
    Public rw_num As String
    Public rz_num As String
    Public tz_num As String
    Public wz_num As String
    Public yb_num As String
    Public yw_num As String
    Public yz_num As String
    Public ze_num As String
    Public zy_num As String
    Public swz_num As String

End Class

Public Class TicketJsonMessages

End Class

 

转换是这样调用的

  Dim user As TicketJson = CType(JsonConvert.DeserializeObject(RetrunValue), TicketJson)

 

这样转换一直报错,谁能帮我看看,谢谢

zd395452476的主页 zd395452476 | 初学一级 | 园豆:112
提问于:2014-01-14 21:51
< >
分享
最佳答案
0

第六行

Public messages As TicketJsonMessages是不是应该 是

Public messages() As TicketJsonMessages

收获园豆:100
angelshelter | 大侠五级 |园豆:9676 | 2014-01-14 22:28

试过把messages修改为数组,但还是不行,用list也试过

zd395452476 | 园豆:112 (初学一级) | 2014-01-14 22:30

可以l,在转换的时候需要加入一个类型的参数

  Dim myTicketJson As New TicketJson
            myTicketJson = CType(JsonConvert.DeserializeObject(RetrunValue, myTicketJson.GetType), TicketJson)

 

zd395452476 | 园豆:112 (初学一级) | 2014-01-14 23:12
其他回答(1)
0

我草,这不是坑爹妈?http://www.51crh.com/thread-125176-1-1.html  高铁网友啊

51crhcom | 园豆:202 (菜鸟二级) | 2015-08-22 23:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册