【发布时间】:2018-09-08 13:43:12
【问题描述】:
我从 API 收到以下类型的响应:
"{"success":false,"error":"不正确的 apikey"}"
"{"success":true,"error":"正确的 apikey"}"
在VBA中,如何知道响应是真还是假?
我当前的代码在下面,并且在 hReq.ResponseText 中得到响应,并且它并不总是固定的(可以向 json 添加更多键)。虽然下面的部分是固定的,我只有在它返回 true 或 false 时才能得到。
"{"成功":false
代码:
Dim hReq As Object
Dim strUrl As String
strUrl = "https://myWebAPI/myMethod?apikey=123456"
Set hReq = CreateObject("MSXML2.XMLHTTP")
With hReq
.Open "GET", strUrl, False
.Send
End With
MsgBox hReq.ResponseText
我知道这是基本问题,但很抱歉我是 VBA 新手。
【问题讨论】: