首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Json解析virustotal的结果

Json解析virustotal的结果
EN

Stack Overflow用户
提问于 2011-06-02 16:53:47
回答 2查看 2.4K关注 0票数 5

今天我在玩virustotal,同时回到了这个表单中的结果

代码语言:javascript
复制
{ "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
}

我想知道如何解析这个结果来填充一个备忘录,比如:

代码语言:javascript
复制
Memo1.Lines.Add(Format('Antivirus: %0s Result: %1s', [...]));

嗯,我真的不知道所有的JSon组件,也许有人能指引我到正确的方向?

致以最亲切的问候,

H.Meiser

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-06-02 18:23:12

解析Json字符串并不困难,可以使用自Delphi2010以来包含的DBXJSON单元。

检查此示例代码

代码语言:javascript
复制
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;

作为附加建议,您必须阅读Json教程才能了解如何解释Json格式,并以这种方式准备使用任何可用的库。

票数 5
EN

Stack Overflow用户

发布于 2011-06-02 17:06:19

我推荐开放源码的JSON库SuperObject和在线JSON检查器,比如http://jsonviewer.stack.hu/http://json.parser.online.fr/ (这个编辑器有一个非常有用的选项,它将类型信息添加到视图中)

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6217595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档