JSON + ASP
Prezados,
Estou precisando consumir um JSON em ASP Classic, porém nunca me deparei com um resultado JSON desta maneira.
{"Generation":{"@attributes":{"version":"3.3.0","timestamp":"1554501899"}},"Options":{"@attributes":{"tempFormat":"c","byteFormat":"auto_binary","datetimeFormat":"utc","refresh":"60000","threshold":"90"}},"Vitals":{"@attributes":{"Hostname":"WIN2K","IPAddr":"127.0.0.1","Kernel":"6.1.7600 (64-bit)","Distro":"Microsoft Windows Server 2008 R2 Enterprise","Distroicon":"WinVista.png","Uptime":"381618","Users":"0","LoadAvg":"","CPULoad":"0","SysLang":"Portuguese - Brazil (1046)","CodePage":"windows-1252","Processes":"58","OS":"WINNT"}},"Network":{},"Hardware":{"@attributes":{"Name":"VMware, Inc. VMware Virtual Platform"},"PCI":{"Device":[{"@attributes":{"Name":"PCI standard PCI-to-PCI bridge","Count":"2"}},{"@attributes":{"Name":"PCI Express standard Root Port","Count":"32"}},{"@attributes":{"Name":"Standard AHCI 1.0 Serial ATA Controller","Manufacturer":"Standard AHCI 1.0 Serial ATA Controller"}},{"@attributes":{"Name":"Intel(R) PRO\/1000 MT Network Connection","Manufacturer":"Intel"}},{"@attributes":{"Name":"Intel(R) PRO\/1000 MT Network Connection #2","Manufacturer":"Intel"}},{"@attributes":{"Name":"Intel(R) PRO\/1000 MT Network Connection #3","Manufacturer":"Intel"}},{"@attributes":{"Name":"LSI Adapter, SAS 3000 series, 8-port with 1068","Manufacturer":"LSI"}},{"@attributes":{"Name":"Intel 82371AB\/EB PCI to ISA bridge (ISA mode)","Manufacturer":"Intel"}},{"@attributes":{"Name":"VMware SVGA 3D","Manufacturer":"VMware, Inc."}},{"@attributes":{"Name":"Intel(R) 82371AB\/EB PCI Bus Master IDE Controller","Manufacturer":"Intel"}},{"@attributes":{"Name":"VMware VMCI Bus Device","Manufacturer":"VMware, Inc."}},{"@attributes":{"Name":"Intel 82443BX Pentium(R) II Processor to PCI Bridge","Manufacturer":"Intel"}}]},"IDE":{"Device":{"@attributes":{"Name":"NECVMWar VMware SATA CD00 ATA Device"}}},"SCSI":{"Device":{"@attributes":{"Name":"VMware Virtual disk SCSI Disk Device","Capacity":"128849011200"}}},"CPU":{"CpuCore":[{"@attributes":{"Model":"Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz","CpuSpeed":"3400","Cache":"0"}},{"@attributes":{"Model":"Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz","CpuSpeed":"3400","Cache":"0"}},{"@attributes":{"Model":"Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz","CpuSpeed":"3400","Cache":"0"}},{"@attributes":{"Model":"Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz","CpuSpeed":"3400","Cache":"0"}}]}},"Memory":{"@attributes":{"Free":"1575329792","Used":"2719170560","Total":"4294500352","Percent":"63"},"Swap":{"@attributes":{"Free":"2833252352","Used":"900726784","Total":"3733979136","Percent":"24"},"Mount":{"@attributes":{"MountPointID":"1","FSType":"swap","Name":"SWAP","Free":"2833252352","Used":"900726784","Total":"3733979136","Percent":"24","MountPoint":"C:\\pagefile.sys"}}}},"FileSystem":{"Mount":[{"@attributes":{"MountPointID":"1","FSType":"","Name":"Removable Disk (3 1\/2 in.)","Free":"0","Used":"0","Total":"0","Percent":"0","MountPoint":"A:"}},{"@attributes":{"MountPointID":"2","FSType":"NTFS","Name":"Local Disk","Free":"16396288","Used":"128725663744","Total":"128742060032","Percent":"100","MountPoint":"C:"}},{"@attributes":{"MountPointID":"3","FSType":"","Name":"Compact Disc","Free":"0","Used":"0","Total":"0","Percent":"0","MountPoint":"D:"}}]},"MBInfo":{},"UPSInfo":{},"Plugins":{},"Errors":{}}
Preciso pegar alguns valores desse resultado.
Esses valores são CPULoad, Memory e Hard Disk.
oJSON.loadJSON("http://127.0.0.1/xml.php?plugin=complete&json")
'Loop through collection
For Each dados In oJSON.data("Vitals")
Set this = oJSON.data("Vitals").item(dados)
processador = this.item("CPULoad")
Next
For Each dados In oJSON.data("Memory")
Set this = oJSON.data("Memory").item(dados)
memoria = this.item("Total")
Next
For Each dados In oJSON.data("FileSystem")
Set this = oJSON.data("FileSystem").item(dados)
if this.item("MountPointID") = "2" then
hd = this.item("Percent")
end if
Next
Tentei de algumas formas, mas sem sucesso.
Alguém teria alguma idéia de como posso pegar esses valores?
Agradeço a atenção de todos.
Discussão (0)
Carregando comentários...