字符串json化输出
//JSON格式展示方法
public static function jsonstr(str){
if (str==""){
return String.Empty;
}
var htmlfile = new ActiveXObject('htmlfile');
htmlfile.IHTMLDocument2_write('<meta http-equiv="x-ua-compatible" content="IE=9" />');
var JSON = htmlfile.parentWindow.JSON;
var obj = JSON.parse(str);
var JSON_format=JSON.stringify(obj, null,4);
return JSON_format;
}
Tab绑定
//绑定tab,展示数据
public BindUITab("接口解密",true)
static function ShowStatusDogs(arrSess: Session[]):String {
if (arrSess.Length < 1) return "<html>Please select one or more Sessions.</html>";
var oSB: System.Text.StringBuilder = new System.Text.StringBuilder();
oSB.Append("<html>");
oSB.Append("<head>");
oSB.Append("<title>解密信息</title>");
oSB.Append("</head>");
oSB.Append("<body><pre>");
var content="";
var living="";
for (var i:int = 0; i<arrSess.Length; i++)
{
var strBody=arrSess[i].GetResponseBodyAsString();
var requestJson=Fiddler.WebFormats.JSON.JsonDecode(strBody);
var str_request_body=arrSess[i].GetRequestBodyAsString();
if(arrSess[i].fullUrl.Contains("XXXXX")){
if (strBody.Contains("content")){
content=requestJson.JSONObject['data']['content'];
//decompress是解密方法
var rst=decompress(content);
var rst_json=jsonstr(rst);
oSB.AppendFormat("{0}: {1}\n", "加密content", content);
oSB.AppendFormat("{0}: {1}\n", "解密content", rst_json);
}
else{
var res='不存在加密字段,无需解密';
oSB.AppendFormat(res);
} }
oSB.Append("</pre></body>");
oSB.Append("</html>");
return oSB.ToString();
}