Consulting

Results 1 to 9 of 9

Thread: JsonConverter question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Mar 2024
    Posts
    20
    Location

    JsonConverter question

    Hi sirs

    i want to catch data from "https://www.twse.com.tw/rwd/zh/afterTrading/MI_INDEX?date=20240327&type=ALLBUT0999&response=json&_=1711564048882"

    i try to use JsonConverte, but it show run-time error "450", but i check ResponseText correct. what mistake in this case ?? code like list, thanks

    Sub FetchAndParseData_1()
        Dim xhr As Object
        Dim URl As String
        Dim response As String
        Dim json As Object
        Dim tables As Object
        Dim data As Object
    URl = "https://www.twse.com.tw/rwd/zh/afterTrading/MI_INDEX?date=20240327&type=ALLBUT0999&response=json&_=1711564048882"
    Set xhr = CreateObject("MSXML2.XMLHTTP")
    xhr.Open "GET", URl, False
        xhr.send
    response = xhr.ResponseText
    ' Parse JSON response
        Set json = JsonConverter.ParseJson(response)
        Debug.Print json("tables")  'this show run-time error
        ' Check if JSON contains "tables" key
        If json.Exists("tables") Then
        Set tables = json("tables")
        Set data = tables(8)("data")
        Debug.Print json("tables")
        Else
        MsgBox "No tables found in JSON response."
        End If
    ' Clean up
        Set xhr = Nothing
    End Sub
    Last edited by Aussiebear; 03-29-2024 at 12:41 AM. Reason: Added code tags to supplied code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •