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

asp.net接收php json传来的值
如题,现在想用asp.net实现接收php json过来的值,
这是PHP JSON后的值

{\"title\":\"3333\",\"summary\":\"333\",\"group_id\":\"27\",\"partner_id\":\"1\",\"system\":\"Y\",\"team_price\":\"1.00\",\"market_price\":\"1.00\",\"product\":\"333\",\"condbuy\":\"\",\"per_number\":\"0\",\"permin_number\":\"1\",\"mobile\":null,\"card\":\"0\",\"bonus\":\"0\",\"address\":null,\"detail\":\"333\",\"notice\":\"333\",\"express\":\"\",\"express_relate\":\"N;\",\"delivery\":\"coupon\",\"state\":\"none\",\"conduser\":\"N\",\"buyonce\":\"N\",\"team_type\":\"normal\",\"sort_order\":\"0\",\"expire_time\":\"1383062400\",\"begin_time\":\"1375113600\",\"end_time\":\"1375200000\",\"reach_time\":\"0\",\"close_time\":\"0\",\"priceremark\":\"2222222\",\"pricesummary\":\"222222222222222222\",\"keywords\":\"22222222\",\"referprice\":\"0.00\",\"sellerprice\":\"0.00\",\"phones\":\"22\",\"checked\":\"N\",\"gold_price\":\"0.00\",\"silver_price\":\"0.00\",\"smsmoban\":\"[\\u4ea7\\u54c1]\\u4e0b\\u5355\\u6210\\u529f\\uff0c\\u7535\\u5b50\\u7f16\\u7801\\uff1a[\\u7f16\\u53f7],\\u53ef\\u6d88\\u8d39[\\u5f20\\u6570]\\u6b21\\uff0c\\u6709\\u6548\\u671f\\uff1a[\\u6709\\u6548\\u671f]\\u3002\\u3010\\u8fd0\\u901a\\u56fd\\u65c5\\u3011\",\"s_id\":\"\",\"allowname\":\"N\",\"validate_time\":\"0\",\"allowtomorrow\":\"N\",\"close\":\"Y\",\"tuan_type\":null,\"traffic_type\":null,\"line_type\":null,\"preday\":\"0\",\"bj_type\":\"0\",\"carpark\":null,\"hoteltype\":null,\"fangtype\":null,\"bedtype\":null,\"partner_level\":\"1\",\"theme_type\":\"1\",\"pepole_type\":\"1\",\"price_type\":\"1\",\"ticket_type\":\"1\",\"partneraddress\":\"22222\",\"trafficguide\":\"3333\",\"deliverydetail\":\"3333\",\"partnertianqi\":\"44\",\"mpnumber\":\"mp122345\",\"create_time\":1375066352,\"author\":\"admin\",\"dayprice\":[{\"id\":\"7\",\"cdate\":\"1374854400\",\"team_id\":\"6\",\"amarket_price\":\"23.00\",\"ayouhui_price\":\"23.00\",\"ahuiyuan_price\":\"23.00\",\"cmarket_price\":\"23.00\",\"cyouhui_price\":\"23.00\",\"chuiyuan_price\":\"23.00\",\"allowdingjin\":\"Y\"}]}


这是我在asp.net里接收的代码,使用的是System.Web.Script.Serialization; 这个类库

string tmp = Request["data"].ToString();//接收POST数据
        //实例化对象
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        //JSON序列化
        string result = serializer.Serialize(tmp);
        //JSON反序列化
        m = serializer.Deserialize<Menpiao>(tmp);

结果报错: 传入的对象无效,应为成员名称。 (1): ....(此处省略php json 的值)

我在本地手动测试通过get方法手动加上 (1):(php json的值), 倒是不报先前的错了,但是报错如下:

无效的 JSON 基元: 。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。