0
我正在嘗試將我們的ERP系統集成到我們的網站中。我能夠從系統中獲得一些json響應。但我真的需要一些幫助解析它。解析經典ASP中的json
我使用ASPJSON(www.aspjson.com)來幫助我。
問題是如何從「數據」中獲取所有字段。我能夠獲得DebtorId,但我無法弄清楚如何獲得其他。
JSON響應:
"Data":{"DebtorId":1,"Data":
[{"Id":"Felt01","Label":"Navn","Value":"Testmedlem"},
{"Id":"Felt14","Label":"Bemærkninger","Value":""},
{"Id":"Felt15","Label":"Oprettet den","Value":null},
{"Id":"Felt16","Label":"Sidst rettet","Value":"2015-12-04T22:56:36"},
{"Id":"Felt23","Label":"Udmeldt","Value":null},
{"Id":"Felt12","Label":"Note","Value":""},
{"Id":"Felt02","Label":"Adresse 1","Value":"Adresse 1"},
{"Id":"Felt03","Label":"Postnr","Value":""},
{"Id":"Felt04","Label":"Bynavn","Value":""},
{"Id":"Felt05","Label":"Mobiltelefon","Value":""},
{"Id":"Felt06","Label":"Adresse 2","Value":""},
{"Id":"Felt07","Label":"Telefon","Value":""},
{"Id":"Felt08","Label":"Efternavn","Value":""},
{"Id":"Felt10","Label":"Email","Value":""},
{"Id":"Felt24","Label":"Aktiv","Value":false},
{"Id":"Felt09","Label":"Grupper og roller","Value":[]},
{"Id":"Felt11","Label":"Medlemskontingent","Value":0},
{"Id":"Felt13","Label":"Medarbejdernr","Value":""},
{"Id":"Felt17","Label":"Ansættelsessted","Value":{"Id":0,"Code":null,"Value":null}},
{"Id":"Felt18","Label":"Land","Value":""},
{"Id":"Felt19","Label":"Medlemsnummer","Value":1},
{"Id":"Felt20","Label":"Donation","Value":0.0},
{"Id":"Felt21","Label":"WebID","Value":0}]},
"WinkasErrorCode":0,"WinKasStatus":0,"WinKasStatusString":"Okay",
"WinKasMessage":null,"ApiVersion":"1.1.888.91",
"ResponseDateTime":"2015-12-04T23:23:19"
傳統的ASP:
Response.Write "<p>Result (single):" & requestBody.data("DebtorId").item(phonenr) & "</p>"
For Each phonenr In requestBody.Data
Set this = requestBody.data("Data").item(Id)
Response.Write _
this.item("type") & ": " & _
this.item("number") & "<br>"
Next
關於在經典中使用JSON有幾個問題ASP。我發現它更容易使用(服務器端)Javascript而不是VBScript作爲腳本語言而不是像ASPJSON這樣的類,請參閱我的答案 - http://stackoverflow.com/questions/30538292/asp-json-object-not-a -collection/30546374#30546374 – John