Reputation: 1
Getting Type Mismatch (Error 13) while using Json PArser in Excel MAcro
Below are the code :
Sub getJsonValue()
Dim FSO As New FileSystemObject
Dim JsonTS As TextStream
Set JsonTS = FSO.OpenTextFile("C:\Users\Card_Link.json", ForReading)
JsonText = JsonTS.ReadAll
JsonTS.Close
Set Json = ParseJson(JsonText)
Set JsonRows = Json("rows")
i = 2
For Each Item In Json
Sheet5.Cells(i, 1).Value = Item("name")
'Sheet5.Cells(i, 2).Value = Item("results")("name")
'Sheet5.Cells(i, 3).Value = Item("results")("responsecode")
i = i + 1
Next
MsgBox ("complete")
End Sub
Getting error on this statement
Sheet5.Cells(i, 1).Value = Item("name")
Can someone please help me to resolve this.
Thanks RJ
Upvotes: 0
Views: 497
Reputation: 43585
Without having any experience with ParseJson, try one of these:
Sheet5.Cells(i, 1).value = item
Sheet5.Cells(i, 1).value = item(0)
Sheet5.Cells(i, 1).value = item.Name
If still none of these works, try like this:
For Each item In Json
Stop
Sheet5.Cells(i, 1).value = item("name")
'Sheet5.Cells(i, 2).Value = Item("results")("name")
'Sheet5.Cells(i, 3).Value = Item("results")("responsecode")
i = i + 1
Next
On the stop, select item
, press Shift+F9 and see what do you have in item
.
Upvotes: 1