问题描述
c{permalink:http://www.virustotal.com/file-scan/report.html?id=7b6b268cbca9d421aabba5f08533d3dcaba50e0f7887b07ef2bd66bf218b35ff-1304089592,
report:[2011-04-29 15: 06:32,
{AVG:Exploit_c.TVH,
AhnLab-V3:PDF / Exploit,
AntiVir:EXP / Pidief.UK ,
Antiy-AVL:Trojan / win32.agent,
Avast:JS:Pdfka-gen,
Avast5:JS:Pdfka-gen ,
BitDefender:Exploit.PDF-JS.Gen,
CAT-QuickHeal:,
ClamAV:,
Comodo :Exploit.JS.Pidief。〜AWQ,
DrWeb:,
Emsisoft:Exploit.JS.Pdfka!IK,
F-Prot :,
F-Secure:Exploit:W32 / Pidief.DEE,
Fortinet:,
GData:,
Ikarus:Exploit.JS.Pdfka,
江敏:,
K7AntiVirus:,
卡巴斯基:Exploit.JS.Pdfka.dnc,
McAfee:,
McAfee-GW-Edition:,
Microsoft:Exploit:Win32 / Pdfjsc.NJ,
NOD32:PDF / Exploit.Pidief.PGD,
Norman:,
PCTools:Trojan.Pidief,
熊猫:,
Prevx:,
上升:,
SUPERAntiSpyware:,
Sophos:Troj / PDFJs-RD,
Symantec:Trojan.Pidief,
TheHacker:,
TrendMicro:TROJ_PIDIEF.VTG,
TrendMicro-HouseCall:TROJ_PIDIEF.VTG,
VBA32:,
VIPRE:Exploit.PDF-JS.Gen(v),
ViRobot:PDF.S.Exploit.74634,
VirusBuster:,
eSafe:,
eTrust-Vet:
}
],
result:1
}
我w想知道如何解析这个结果来填写一个备忘录,如:
Memo1.Lines.Add格式('防病毒:%0s结果:%1s',[...]));
嗯,我真的不知道所有的JSon组件,可能有人可以直接我正确的方向在这里?
最诚挚的问候,
H.Meiser
$ b $解析Json字符串并不难,你可以使用单元包含在delphi 2010中。检查此示例代码
使用
DBXJSON;
程序TForm1.ParseString(const AString:string);
var
json:TJSONObject;
jPair:TJSONPair;
jValue:TJSONValue;
jcValue:TJSONValue;
l,i:整数;
begin
json:= TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(AString),0)作为TJSONObject;
尝试
//在这种情况下,获取对评估索引为1
jPair:= json.Get(1);
//将JsonValue转换为TJSONArray以访问数组的元素
jValue:= TJSONArray(jPair.JsonValue).Get(1);
l:= TJSONArray(jValue).Size;
for i:= 0 to l-1 do
begin
//获取数组的元素
jcValue:= TJSONArray(jValue).Get(i);
//获取指向i元素的对
jPair:= TJSONPair(jcValue);
//显示结果
Memo1.Lines.Add(格式('Antivirus%s Result%s',[jPair.JsonString.Value,jPair.JsonValue.Value]));
结束
finally
json.Free;
结束
结束
作为其他建议,您必须阅读Json教程,了解如何解释Json格式,以这种方式必须准备使用任何可用的库。
I was playing around with the virustotal api today while becoming back the result in this form:
{ "permalink" : "http://www.virustotal.com/file-scan/report.html?id=7b6b268cbca9d421aabba5f08533d3dcaba50e0f7887b07ef2bd66bf218b35ff-1304089592",
"report" : [ "2011-04-29 15:06:32",
{ "AVG" : "Exploit_c.TVH",
"AhnLab-V3" : "PDF/Exploit",
"AntiVir" : "EXP/Pidief.UK",
"Antiy-AVL" : "Trojan/win32.agent",
"Avast" : "JS:Pdfka-gen",
"Avast5" : "JS:Pdfka-gen",
"BitDefender" : "Exploit.PDF-JS.Gen",
"CAT-QuickHeal" : "",
"ClamAV" : "",
"Comodo" : "Exploit.JS.Pidief.~AWQ",
"DrWeb" : "",
"Emsisoft" : "Exploit.JS.Pdfka!IK",
"F-Prot" : "",
"F-Secure" : "Exploit:W32/Pidief.DEE",
"Fortinet" : "",
"GData" : "",
"Ikarus" : "Exploit.JS.Pdfka",
"Jiangmin" : "",
"K7AntiVirus" : "",
"Kaspersky" : "Exploit.JS.Pdfka.dnc",
"McAfee" : "",
"McAfee-GW-Edition" : "",
"Microsoft" : "Exploit:Win32/Pdfjsc.NJ",
"NOD32" : "PDF/Exploit.Pidief.PGD",
"Norman" : "",
"PCTools" : "Trojan.Pidief",
"Panda" : "",
"Prevx" : "",
"Rising" : "",
"SUPERAntiSpyware" : "",
"Sophos" : "Troj/PDFJs-RD",
"Symantec" : "Trojan.Pidief",
"TheHacker" : "",
"TrendMicro" : "TROJ_PIDIEF.VTG",
"TrendMicro-HouseCall" : "TROJ_PIDIEF.VTG",
"VBA32" : "",
"VIPRE" : "Exploit.PDF-JS.Gen (v)",
"ViRobot" : "PDF.S.Exploit.74634",
"VirusBuster" : "",
"eSafe" : "",
"eTrust-Vet" : ""
}
],
"result" : 1
}
I would like to know how one can parse this result to fill a memo like:
Memo1.Lines.Add(Format('Antivirus: %0s Result: %1s', [...]));
Well, I really have no clue about all the JSon components which might be around to maybe someone can direct me to the right direction here?
Kindest regards,
H.Meiser
Parsing Json string is not difficult, you can use the DBXJSON
unit included since delphi 2010.
check this sample code
Uses
DBXJSON;
procedure TForm1.ParseString(const AString: string);
var
json : TJSONObject;
jPair : TJSONPair;
jValue : TJSONValue;
jcValue : TJSONValue;
l,i : Integer;
begin
json := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(AString),0) as TJSONObject;
try
//get the pair to evaluate in this case the index is 1
jPair := json.Get(1);
//cast the JsonValue to TJSONArray to access the elements of the array
jValue := TJSONArray(jPair.JsonValue).Get(1);
l:=TJSONArray(jValue).Size;
for i:=0 to l-1 do
begin
//get the i element of the array
jcValue := TJSONArray(jValue).Get(i);
//get the pair pointing to the i element
jPair := TJSONPair(jcValue);
//show the result
Memo1.Lines.Add(Format('Antivirus %s Result %s',[jPair.JsonString.Value,jPair.JsonValue.Value]));
end;
finally
json.Free;
end;
end;
As additional recommendation you must read a Json tutorial to learn how interpret the Json format and in this way you must be preparated to use any library available.
这篇关于Json解析结果来自virustotal api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!