Parse JSON into Excel

scarlett3

Board Regular
Joined
Jan 21, 2005
Messages
73
Office Version
  1. 365
Platform
  1. Windows
Hi

I have been using the Jsonconverter vba parser available via https://github.com/VBA-tools/VBA-JSON to extract the data from json files such as https://stats.europeantour.com/v1/season/2019/players/strokes-gained/off-the-tee. This has been very easy to set up and it works.

However, the following json url looks virtually identical - https://stats.europeantour.com/api/v2/events/2019084/stats/strokes-gained-off-the-tee - but running the SGOTT2 macro in the file below generates a 'Run-time error '13': Type mismatch' error.

The file is available here: https://www.dropbox.com/s/913vec5i8rmf8kw/book1.xls?dl=0

I can't see what the issue is to fix.

Can anyone help?

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
ParseJson in SGOTT2 returns a dictionary with 2 keys, 'statsDetailedType' and 'statsData'.

The value for the first key is simply the string 'STROKES_GAINED_OFF_THE_TEE', whereas the value for 'statsData' is a dictionary.

To access that dictionary try this.
Code:
    For Each Item In JSON("statsData")

        Sheets("OTT").Cells(i, 7).Value = Item("firstName")
        Sheets("OTT").Cells(i, 8).Value = Item("lastName")
        Sheets("OTT").Cells(i, 9).Value = Item("average")
        Sheets("OTT").Cells(i, 10).Value = Item("totalRounds")
        Sheets("OTT").Cells(i, 11).Value = Item("id")

        i = i + 1
   Next Item
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top