ÕýÎÄ
ÍøÂçÖÐÊý¾Ý´«Êä¾³£ÊÇxml»òÕßjson£¬ÏÖÔÚ×öµÄÒ»¸öÏîĿ֮ǰµ÷ÆäËûϵͳ½Ó¿Ú¶¼ÊÇ·µ»ØµÄxml¸ñʽ£¬¸Õ¸ÕÓöµ½Ò»¸ö·µ»Øjson¸ñʽÊý¾ÝµÄ½Ó¿Ú£¬Í¨¹ýÀý×ÓÓÉÒ×µ½ÄÑ×ܽáһϴ¦Àí¹ý³Ì£¬Ï£ÍûÄÜ°ïµ½ºÍÎÒÒ»Ñù¿ªÊ¼²»»áµÄÅóÓÑ¡£
Ò»¡¢C#´¦Àí¼òµ¥jsonÊý¾Ý
jsonÊý¾Ý£º
ÎÒÕâÀïÊÇÒÔjsonmy1.txtÎļþµÄÐÎʽ±£´æÔÚdÅÌjsonÎļþ¼ÐÏ¡£
¹¹Ôì¶ÔÏó£º
¶þ¡¢C#´¦Àí°üº¬¶ÔÏóµÄjsonÊý¾Ý
jsonÊý¾Ý£ºjsonmy2.txt
¹¹Ôì¶ÔÏó£º
ת»»¹ý³Ì£º
JsonMy2() { ); JavaScriptSerializer js = new JavaScriptSerializer(); //ʵÀý»¯Ò»¸öÄܹ»ÐòÁл¯Êý¾ÝµÄÀà ToJsonMy2 list = js.Deserialize<ToJsonMy2>(json); result = list.result; string res_info = list.res_info; string order_num = list.queryorder_info.order_num; string orderdetail = list.queryorder_info.orderdetail; }Èý¡¢C#´¦Àí°üº¬¶ÔÏó¡¢Êý×éµÄjsonÊý¾Ý
jsonÊý¾Ý£ºjsonmy4.txt
¹¹Ôì¶ÔÏó£º
public struct ToJsonMy3 { public string result { get; set; } public string res_info { get; set; } public queryorder_info queryorder_info; } public struct queryorder_info { public string order_num { get; set; } public List<orderdetail> orderdetail;//Êý×é´¦Àí }; public struct orderdetail { public string CFTUin { get; set; } public string CancelDeadline { get; set; } public string CheckInDate { get; set; } public string CheckOutDate { get; set; } public string CityID { get; set; } public string CurrencyCode { get; set; } public string HotelID { get; set; } public string HotelName { get; set; } public string ListID { get; set; } public string PayAmt { get; set; } public string PayType { get; set; } public string RommsCnt { get; set; } public string SPTransID { get; set; } public string State { get; set; } };ת»»¹ý³Ì£º
JsonMy4() { ); JavaScriptSerializer js = new JavaScriptSerializer(); //ʵÀý»¯Ò»¸öÄܹ»ÐòÁл¯Êý¾ÝµÄÀà ToJsonMy3 list = js.Deserialize<ToJsonMy3>(json); result = list.result; string res_info = list.res_info; string order_num = list.queryorder_info.order_num; List<orderdetail> orderdetail = list.queryorder_info.orderdetail; string CFTUin = orderdetail[0].CFTUin; string HotelName = orderdetail[0].HotelName; string ListID = orderdetail[1].ListID; string State = orderdetail[2].State; }ÒÔÉÏ´úÂëÀ´×Ô£º
ÔÚÏîÄ¿ÖÐÒ²Óöµ½ÁËʹÓÃJSONµÄÇé¿ö£¬¾Í°Ñת»¯¹ý³ÌдһÏ¡£
1.´ÓÊý¾Ý¿â»ñÈ¡µÄjsonÊý¾ÝΪ£º
[{:,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,::,:,::,:,::,::,:,:,::,:,::,:,:""}]
¡¡