问题
This is json
code (https://textsaver.flap.tv/lists/3ic4)
and i am trying
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
I want to print TEXT underbelow mentioned point. its in picture also highlighted in blue.
json>[data]>{1}>CH_OPENING_PRICE & CH_CLOSING_PRICE.
It will be more helpful if anyone suggest me any website or book for basic idea about trim text from nested json.
回答1:
First of all put json("data") in a variable:
set data = json("data")
'maybe you don't need the "set" keyword there, check documentation to your json library
Then iterate the data
For Each dataitem In data
r = dataitem("CH_OPENING_PRICE")
r1 = dataitem ("CH_CLOSING_PRICE")
Debug.Print r
Debug.Print r1
Next
来源:https://stackoverflow.com/questions/63098534/print-specific-data-with-json-perse