I'm receiving a
runtime error 13 Type mismatch
at the line Cells(i,1).value=item("fp").
Dont know why the item can't be selected. As you can observe the json file it has "fp" value as "042018"
Sub Jsonread()
Dim FSO As New FileSystemObject
Dim JsonTS As TextStream
Dim jsonText As String
Dim jsonObject As Object
Dim item As variant
Set JsonTS = FSO.OpenTextFile("C:\Users\Abd\retoffline_others.json", ForReading)
jsonText = JsonTS.ReadAll
JsonTS.Close
Dim i As Long
Set jsonObject = JsonConverter.ParseJson(jsonText)
i = 3
For Each item In jsonObject
Cells(i, 1) = item("fp")
Cells(i, 2) = item("sply_ty")
i = i + 1
Next
End Sub
An extract of the json looks like this
{
"name": "Flip",
"fp": "042018",
"filing_typ": "M",
"gt": 0,
"cur_gt": 0,
"b2cs": [
{
"csamt": 0,
"sply_ty": "INTRA"
},
jsonObjectisNothingcheck before using it in the loop:If jsonObject Is Nothing Then MsgBox "It is Nothing":Exit Sub• If it is nothing that means your parsing went wrong or your file wasn't read proberly. Check the value ofjsonTexttoo.item As Variantinstead of anObject. But actually I think it should work.