日期:2014-05-17  浏览次数:20472 次

c# 获取JSON 转换小问题 (初学ajax..)
javascript 传来 
json = {"client_select":{"Standard":{"how_much_room":1},"Family":{"how_much_room":2,"additional_chop_id_list" : ["2","3"]}},"check_in":"2014-02-21","check_out":"2014-02-23","discount_rate":"","total_all_room_price":"183.05"}

c# 
  var json = context.Request["json"];
                Dictionary<string, object> obj = jss.Deserialize<Dictionary<string, object>>(json);
                string check_in = obj["check_in"].ToString();
                string check_out = obj["check_out"].ToString();
                string discount_rate = obj["discount_rate"].ToString();
                double total_all_room_price_from_client = Convert.ToDouble(obj["total_all_room_price"]);


client_select 该怎么获取呢? 
Dictionary<string, Handler_client_select> client_select = obj["client_select"] as Dictionary<string, Handler_client_select>; 类似要这样
   public class Handler_client_select
            {
                public int how_much_room { get; set; }
                public ArrayList additional_chop_id_list { get; set; }            
            }


暂时用的方法是js 序列化多一次,然后c# 反序列化多一次
Dictionary<string, Handler_client_select> client_select = jss.Deserialize<Dictionary<string,Handler_client_select>>(obj["client_select"].ToString()); 
高手请指导一下吧!万分感激 !




------解决方案--------------------
用LitJSON不行吗?
------解决方案--------------------
http://www.cnblogs.com/usharei/archive/2012/04/24/2467578.html  附个入门教程