JSON

C#´¦ÀíJSON Êý¾Ý

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-06-28 11:00 ÎÒÒªÆÀÂÛ( )

C#´¦ÀíJSON Êý¾Ý,ÍøÂçÖÐÊý¾Ý´«Êä¾­³£ÊÇxml»òÕßjson£¬ÏÖÔÚ×öµÄÒ»¸öÏîĿ֮ǰµ÷ÆäËûϵͳ½Ó¿Ú¶¼ÊÇ·µ»ØµÄxml¸ñʽ£¬¸Õ¸ÕÓöµ½Ò»¸ö·µ»Øjson¸ñʽÊý¾ÝµÄ½Ó¿Ú£¬Í¨¹ýÀý×ÓÓÉÒ×

ÕýÎÄ

ÍøÂçÖÐÊý¾Ý´«Êä¾­³£ÊÇxml»òÕßjson£¬ÏÖÔÚ×öµÄÒ»¸öÏîĿ֮ǰµ÷ÆäËûϵͳ½Ó¿Ú¶¼ÊÇ·µ»ØµÄxml¸ñʽ£¬¸Õ¸ÕÓöµ½Ò»¸ö·µ»Øjson¸ñʽÊý¾ÝµÄ½Ó¿Ú£¬Í¨¹ýÀý×ÓÓÉÒ×µ½ÄÑ×ܽáһϴ¦Àí¹ý³Ì£¬Ï£ÍûÄÜ°ïµ½ºÍÎÒÒ»Ñù¿ªÊ¼²»»áµÄÅóÓÑ¡£
Ò»¡¢C#´¦Àí¼òµ¥jsonÊý¾Ý
jsonÊý¾Ý£º

{:,:,:}

ÎÒÕâÀïÊÇÒÔjsonmy1.txtÎļþµÄÐÎʽ±£´æÔÚdÅÌjsonÎļþ¼ÐÏ¡£

¹¹Ôì¶ÔÏó£º

public struct ToJsonMy { res_info { get; set; } public string queryorder_info { get; set; } } JsonMy() { );//Jsonstrº¯Êý¶ÁÈ¡jsonÊý¾ÝµÄÎı¾txt ¡¡¡¡¡¡¡¡¡¡¡¡ JavaScriptSerializer js = new JavaScriptSerializer(); //ʵÀý»¯Ò»¸öÄܹ»ÐòÁл¯Êý¾ÝµÄÀà ToJsonMy list = js.Deserialize<ToJsonMy>(json); result = list.result; ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ string res_info = list.res_info; string queryorder_info = list.res_info; }

¶þ¡¢C#´¦Àí°üº¬¶ÔÏóµÄjsonÊý¾Ý
jsonÊý¾Ý£ºjsonmy2.txt

{:,:,:{:,:}}


¹¹Ôì¶ÔÏó£º

public struct ToJsonMy2 { 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 string orderdetail { get; set; } };

ת»»¹ý³Ì£º

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Êý¾ÝΪ£º

[{:,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,:::,:,:,:::,::,:,:,::,:,::,:,::,::,:,:,::,:,::,:,:""}]

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • JSON ½Ì³Ì£¨Ò»£©

    JSON ½Ì³Ì£¨Ò»£©

    2017-06-28 11:05

  • jquery,phpÖ®¼äµÄajax¹ØϵÒÔ¼°json

    jquery,phpÖ®¼äµÄajax¹ØϵÒÔ¼°json

    2017-06-28 10:01

  • cJSONѧϰ±Ê¼Ç Ðø¼¯

    cJSONѧϰ±Ê¼Ç Ðø¼¯

    2017-06-28 08:03

  • Android ½âÎöJSONÊý¾Ý¸ñʽ

    Android ½âÎöJSONÊý¾Ý¸ñʽ

    2017-06-26 18:04

ÍøÓѵãÆÀ
Ô