Portable Dictionaries in Shortcuts

Many of my Shortcuts rely on dictionaries as a sort of switch statement. For example, I choose from a dictionary list which then modifies a DEVONthink To Go URL scheme and routes new documents based on my selection.

Dictionary Select

It works marvelously but since Shortcuts doesn’t make it very easy to reuse dictionaries, it can be tedious recreating them from scratch in each new shortcut. That is, until I realized that Shortcuts dictionaries can be created from raw JSON.

I create the dictionary once and then route that to my clipboard…

Clipboard

Now I have the JSON that is the foundation of the specific dictionary. I can reuse this dictionary by reading it in as text to a “Choose from List” action…

JSON Text

I could also route this JSON and save it in iCloud Drive instead of the clipboard. In the future I then read it into any shortcut that needs to reuse the same dictionary. The great thing about this method is that I can edit the single JSON text file (in Textastic for example) and the change is made to all of my shortcuts that use this dictionary.

JSON Edit

Of course, it would be a lot easier if Shortcuts had “copy and paste” of actions and action blocks but this is a pretty good workaround for dictionaries. My hope is that Shortcuts improves the editor with reusable dictionaries and better reuse of custom actions across Shortcuts. It’s hard to make a power user programming environment that is also approachable for people that have never created a custom script. The current Shortcuts app is failing at both in my opinion. This workaround is a hack, not a feature.