Open URLs in a JSON File

I have a json file like this:

{"Google":"https://www.google.co.uk/", "YouTube":"https://www.youtube.com/", "eBay":"https://www.ebay.co.uk/"}

I'm after a macro that reads the json file and asks me what web page I want to open. If I input for example 'eBay', I want the macro to open https://www.ebay.co.uk/. Is this possible?

Hey Ross,

Don't use a JSON file – use a plain text file and a Prompt With List action.

Format the file like this:

URL__Item Name

Only the item name will be displayed.

You have to delete the β€œ__Item Name” from the end of the returned item, but that's easy with a find/replace action.

This is the simplest way to do what you want.

-Chris

Just in case "Don't use a JSON file" sounds like "I wouldn't start from here, if I was you" in response to a request for directions:

(Getting Keyboard Maestro to derive the URL__Item Name lines automatically from your JSON source)

menu From JSON.kmmacros (3.6 KB)

1 Like

Many thanks for replies. The json file is already used for a different purpose, so I want to avoid copying stuff from the json into Keyboard Maestro (because whenever the json file is updated, I would also need to update data in Keyboard Maestro).

Instead, I'm after a way for Keyboard Maestro to read the json file by importing it into Keyboard Maestro. Is this possible?

A Keyboard Maestro Read File to Variable action works well for that:

menu From JSON file.kmmacros (3.6 KB)

That's perfect thanks.

1 Like