C#如何把ajax返回的数据转为json
ajax读回来的是如下:
{"code":0,"crumb":"0aadce06967cfc2c3fe5569b6ce5e914","msg":"\u64cd\u4f5c\u6210\u529f","data":"<div class=\"replyform picwrap all_comment\">\n\t<span class=\"icon_pigeon replyformSuccess\">\u53d1\u5e03\u6210\u529f<\/span>\n\t<form method=\"post\" action=\"\/ajax\/json\/pushfeed\/pushreply\" style=\"zoom:1\">\n\t\t<input type=\"hidden\" class=\"replynoteid\" name=\"feedid\" value=\"1157435702\"\/>\n\t\t<a class=\"closer close_gray ac_close\" href=\"javascript:void(0)\">\u5173\u95ed<\/a>\n\t\t<p>\u8bc4\u8bba\u4e24\u53e5\uff1a<\/p>\n\t\t<table border=\"0\" class=\"txtar\">\n\t\t <tr>\n\t\t\t <td><textarea name=\"text\" cols=\"45\" rows=\"5\" class=\"nolimit\">\u56de\u590d@_L6228815: <\/textarea><\/td>\n\t\t <\/tr>\n\t\t<\/table>\n\t\t<input type=\"hidden\" name=\"from\" value=\"reply\"\/>\n\t\t<div class=\"editor_app clearfix\">\n\t\t \t\t <a href=\"javascript:void(0)\" class=\"icon_phiz ac_show_face\" srv=\"\/ajax\/json\/face\/get\">\u8868\u60c5<\/a> \n\t\t \t\t <input type=\"checkbox\" name=\"forward_note\" class=\"check-margin\" ><span class=\"gray\">\u540c\u65f6\u8f6c\u53d1<\/span>\n\t\t \t\t<\/div>\n\t\t<div class=\"editor_app clearfix\">\n\t\t <p class=\"right\"><span class=\"words\"><em class=\"limit\">140<\/em><\/span><button class=\"b-default ac_reply_submit\" type=\"button\"><span>\u53d1\u5e03<\/span><\/button><\/p>\n\t\t<\/div>\n\t<\/form>\n\t<ul class=\"replyList\">\n\t\t\t\t\t\t<li feedid='1161267279' anthorsn='\u56de\u590d@_L6228816: ' class=\"topline\" >\n\t\t\t\t<span class=\"actor\" title=\"\u6768\u6625(@_L6228816)\">\n\t\t<a href=\"_L6228816?sid=0\">\u6768\u6625<\/a>:\n\t<\/span>\n\t\u56de\u590d<em rel=\"@_L39515734\"><a href=\"\/_L39515734\">\u6731\u82f1<\/a>(@_L39515734)<\/em>: \u4e0d\u662f\u554a\uff0c\u5f88\u597d\u73a9\n\t<span class=\"props\">04\u670818\u65e5 22:32<\/span>\n\t<span class=\"props\">\u6765\u81ea\u7f51\u9875<\/span>\n\t\t<a href=\"javascript:void(0)\" class=\"ac_feed_reply_delete comment_delete\" srv=\"\/ajax\/json\/pushfeed\/delfeed\/feedid=1161267279\" title=\"\u5220\u9664\u6768\u6625\u7684\u8bc4\u8bba\">\u5220\u9664<\/a>\n\t <a href=\"javascript:void(0)\" class=\"comment_app ac_replylist_addreply\">\u56de\u590d<\/a>\n<\/li>\n\t\t\t\t\t<li feedid='1161266172' anthorsn='\u56de\u590d@_L39515734: ' >\n\t\t\t\t<span class=\"actor\" title=\"\u6731\u82f1(@_L39515734)\">\n\t\t<a href=_L39515734?sid=0\">\u6731\u82f1<\/a>:\n\t<\/span>\n\t\u4e0d\u597d\u73a9\n\t<span class=\"props\">04\u670818\u65e5 22:30<\/span>\n\t<span class=\"props\">\u6765\u81ea\u7f51\u9875<\/span>\n\t\t<a href=\"javascript:void(0)\" class=\"ac_feed_reply_delete comment_delete\" srv=\"\/ajax\/json\/pushfeed\/delfeed\/feedid=1161266172\" title=\"\u5220\u9664\u6731\u82f1\u7684\u8bc4\u8bba\">\u5220\u9664<\/a>\n\t <a href=\"javascript:void(0)\" class=\"comment_app ac_replylist_addreply\">\u56de\u590d<\/a>\n<\/li>\n\t\t\t\t<\/ul>\n\t\t<p>\n\t\t<a class=\"floatright\" href=\"\/feed\/single.php?feedid=1157435702&type=reply\">\u67e5\u770b\u5168\u90e8\u8bc4\u8bba<span class=\"fam_sun\">>><\/span><\/a>\n\t\t\t<\/p>\n\t<\/div>"}
怎么把他转成json数据格式,如下:
code
0
crumb
"0aadce06967cfc2c3fe5569b6ce5e914"
data
"<div class="replyform picwrap all_comment"> <span class="icon_pigeon replyformSuccess">发布成功</span> <form method="post" action="/ajax/json/pushfeed/pushreply" style="zoom:1"> <input type="hidden" class="replynoteid" name="feedid" value="1157435702"/> <a class="closer close_gray ac_close" href="javascript:void(0)">关闭</a> <p>评论两句:</p> <table border="0" class="txtar"> <tr> <td><textarea name="text" cols="45" rows="5" class="nolimit">回复@_L6228815: </textarea></td> </tr> </table> <input type="hidden" name="from" value="reply"/> <div class="editor_app clearfix"> <a href="javascript:void(0)" class="icon_phiz ac_show_face" srv="/ajax/json/face/get">表情</a> <input type="checkbox" name="forward_note" class="check-margin" ><span class="gray">同时转发</span> </div> <div class="editor_app clearfix"> <p class="right"><span class="words"><em class="limit">140</em></span><button class="b-default ac_reply_submit" type="button"><span>发布</span></button></p> </div> </form> <ul class="replyList"> <li feedid='1161267279' anthorsn='回复@_L6228815: ' class="topline" > <span class="actor" title="张三(@_L6228817)"> <a href="L6228817?sid=0">张三</a>: </span> 回复<em rel="@_L39515733"><a href="/_L39515733">李四</a>(@_L39515734)</em>: 不是啊,很好玩 <span class="props">04月18日 22:32</span> <span class="props">来自网页</span> <a href="javascript:void(0)" class="ac_feed_reply_delete comment_delete" srv="/ajax/json/pushfeed/delfeed/feedid=1161267279" title="删除张三的评论">删除</a> <a href="javascript:void(0)" class="comment_app ac_replylist_addreply">回复</a> </li> <li feedid='1161266172' anthorsn='回复@_L39515734: ' > <span class="actor" title="李四(@_L39515734)"> <a href="_L39515734?sid=0">李四</a>: </span> 不好玩 <span class="props">04月18日 22:30</span> <span class="props">来自网页</span> <a href="javascript:void(0)" class="ac_feed_reply_delete comment_delete" srv="/ajax/json/pushfeed/delfeed/feedid=1161266172" title="删除李四的评论">删除</a> <a href="javascript:void(0)" class="comment_app ac_replylist_addreply">回复</a> </li> </ul> <p> <a class="floatright" href="/feed/single.php?feedid=1157435702&type=reply">查看全部评论<span class="fam_sun">>></span></a> </p> </div>"
msg
"操作成功"
不是用javascript的 eval。而是在C#后台代码怎么转哦。
[解决办法]
参看:http://www.soaspx.com/dotnet/csharp/csharp_20100713_5052.html
[解决办法]
Newtonsoft.Json.dll
[解决办法]
Newtonsoft.Json.dll
这个json dll很好啊。
[解决办法]