0

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.

enter image description here

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.

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
AAdi
  • 15
  • 4

1 Answers1

0

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


armagedescu
  • 1,758
  • 2
  • 20
  • 31