0

这是json代码(https://textsaver.flap.tv/lists/3ic4),我正在尝试

Sub test()
Dim req As New MSXML2.XMLHTTP60
Dim URL As String, ws As Worksheet
Dim json As Object, r, r1 As String
URL = "https://www.nseindia.com/api/quote-equity?symbol=DIVISLAB"
With req
.Open "GET", URL, False
.send
Set json = JsonConverter.ParseJson(.responseText)
r = json("data")(1)("CH_OPENING_PRICE")
r1 = json("data")(1)("CH_CLOSING_PRICE")
End With

Debug.Print r
Debug.Print r1
End Sub

我想在下面提到的点下打印 TEXT。它在图片中也以蓝色突出显示。

在此处输入图像描述

json>[data]>{1}>CH_OPENING_PRICE & CH_CLOSING_PRICE.

如果有人向我推荐任何网站或书籍以获取有关从嵌套 json 修剪文本的基本想法,那将会更有帮助。

4

1 回答 1

0

首先将 json("data") 放入一个变量中:

   set data = json("data")
      'maybe you don't need the "set" keyword there, check documentation to your json library

然后迭代数据

For Each dataitem In data
    r = dataitem("CH_OPENING_PRICE")
    r1 = dataitem ("CH_CLOSING_PRICE")
    Debug.Print r
    Debug.Print r1
Next


于 2020-07-26T11:02:39.583 回答