gpt4 book ai didi

json - 使用 ASP Xtreme Evolution 在经典 ASP 中解析 JSon

转载 作者:行者123 更新时间:2023-12-04 13:51:16 25 4
gpt4 key购买 nike

我正在处理一个经典的 ASP 项目,我使用 ASP Xtreme Evolution 来解析 JSon 数据(在此处找到:http://zend.lojcomm.com.br/entries/classic-asp-json-revisited/)

无论如何...我正确获取了大部分 JSON 数据,但现在我被困在一个数组上。

JSon 看起来像这样:

{
"Product": {
"ID": "6666",
"Name": "Tha name",
"ArticleGroup": [
{
"@handleas": "array",
"Title": "Title 1",
"Article": {
"ID": "777",
"Label": "Label 1",
}
},
{
"@handleas": "array",
"Title": "Title 2",
"Article": {
"ID": "888",
"Label": "Label 2",
}
}
]
}
}
}

ASP 看起来像这样:

set xmlHTTP = server.createobject("MSXML2.ServerXMLHTTP.6.0")
xmlHTTP.open "GET", "http://source.of.json", false
xmlHTTP.send()
ProductFeed = xmlHTTP.ResponseText

dim ProductInfo : set ProductInfo = JSON.parse(join(array(ProductFeed)))

dim key : for each key in ProductInfo.Product.keys()
Response.Write ProductInfo.Product.ID ' Prints 6666
Response.Write ProductInfo.Product.Name ' Prints Tha Name
Next
set ProductInfo = nothing

我的问题是我不知道如何访问 ArticleGroup 中的信息。我得到的只是 [object Object]、[object Object] 或一个空值。

有人有什么想法吗?

谢谢!

最佳答案

尝试以下操作(基于给定的 JSON):

Dim ArticleGroup

dim key : For Each key in ProductInfo.Product.keys()
Response.Write ProductInfo.Product.ID ' Prints 6666
Response.Write ProductInfo.Product.Name ' Prints Tha Name

For Each ArticleGroup In ProductInfo.Product.Get("ArticleGroup") '' iterate all ArticleGroup entries
Response.write ArticleGroup.Get("Title") '' get the correct key value
Next
Next

您需要遍历所有 ArticleGroup 条目并通过 .get(keyName) 获取值。否则它将返回 JScript 函数体。

关于json - 使用 ASP Xtreme Evolution 在经典 ASP 中解析 JSon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10499272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com