经典asp json asp Xtreme遍历json对象

经典asp json asp Xtreme遍历json对象,json,foreach,asp-classic,Json,Foreach,Asp Classic,我不知道如何在经典asp中遍历此json: {"recs": [ {"0": { "idOrder":"1", "idProduct":10, "description": "prod 10", "orgweight":5, "newweight":5,

我不知道如何在经典asp中遍历此json:

{"recs": 
    [
        {"0":
            {
                "idOrder":"1",
                "idProduct":10,
                "description":
                "prod 10",
                "orgweight":5,
                "newweight":5,
                "rootsku":"sku1",
                "size":"12-18 Months"
            },
        "1":
            {
                "idOrder":"2",
                "idProduct":20,
                "description":"prod 20",
                "orgweight":5,
                "newweight":5,
                "rootsku":"sku2",
                "size":"12-18 Months"
            }
        }
    ]
}

sub updateWeights()
    dim jsonOBJ : set jsonOBJ= JSON.parse(join(array(myJsonString)))
    For Each rec in jsonOBJ("recs")
            'I want to compare orgweight vs newweight and update the db accordingly
    Next
end sub

我错过了什么?这不是在经典ASP中遍历JSON对象的正确方法吗?

我在Xtreme中找到了如何编写我想要的JSON的方法。我的结局是:

    dim jsonOBJ : set jsonOBJ= JSON.parse(join(array(Request.Form("data"))))
{
    "prodArray": [{
        "idOrder": "266269",
        "idProduct": 281953,
        "description": "description 1",
        "orgweight": 2,
        "newweight": 3,
        "rootsku": "sku1",
        "size": "2T"
    }, {
        "idOrder": "266269",
        "idProduct": 274437,
        "description": "description 2 ",
        "orgweight": 2,
        "newweight": 2,
        "rootsku": "sku2",
        "size": "3T"
    }, {
        "idOrder": "266269",
        "idProduct": 268546,
        "description": "description3 ",
        "orgweight": 1,
        "newweight": 2,
        "rootsku": "sku3",
        "size": "3T"
    }]
}
以及遍历数组的代码:

    dim key: For Each key in jsonOBJ.prodArray.keys()
        set rec=jsonOBJ.prodArray.get(i)
        if rec.orgweight <> rec.newweight then
            query = "update products set weight=" & rec.newweight & " where  rootsku = '" & rec.rootsku & "' and size = '" & rec.size & "'"
            connTemp.execute(query)
            query="update Product_Weights_master set [" & rec.size & "] = " & rec.newweight & " where sku = '" & rec.rootsku & "'"
            connTemp.execute(query)
        end if
        i=i+1
    next
dim key:jsonOBJ.prodArray.keys()中的每个键
set rec=jsonOBJ.prodArray.get(i)
如果rec.orgweight rec.newweight,则
query=“update products set weight=“&rec.newweight&”其中rootsku='”&rec.rootsku&“and size='”&rec.size&“”
connTemp.execute(查询)
query=“update Product_Weights_master set[”&rec.size&“]=”&rec.newweight&“where sku=”&rec.rootsku&“”
connTemp.execute(查询)
如果结束
i=i+1
下一个