Add to dictionary in Data Jar

I see there is an add to list action in Shortcuts for Data Jar but I don’t see a add to dictionary for Data Jar. Am I missing something?

Get the dictionary, add the key value pair within the structure of the dictionary, it can have nested values, lists/arrays, other dictionaries, etc., and then set the value. The add to list action is just for adding something to the end of a single-dimension list.

I got it now. Thanks.

I found this old thread, which is also what I’m trying to do! :slight_smile:

I do not see a GET DICTIONARY option for Data View in Shortcuts.

I do see GET TYPE OF VALUE, and when I pass it my path, it returns DICTIONARY.

What I’m trying to do is build a HABIT TRACKER that allows me to check off several items. These would all be booleans, I’d imagine. Example:

  • runToday: true
  • learnDictionariesToday: false
  • etc

I’d then want to be able to use the stored data to do things like:

  • Count the days in a row I ran.
  • Get a total number of days I ran.
  • Get the date of my last run.
  • etc.

Here’s what I’ve tried:

Get the date
Format the date
Set a variable with the resulting date
Nothing
Text: {date}-ran
Set a variable with Text as myDailyRunningKey
Nothing
Next, I prompt to choose from a list with two options: true and false
I store the chosen item in a new variable called didIt

I can’t figure out how to store key value pairs for the date and the true or false answer to if I ran or not.
It seems like I need a dictionary, but Shortcuts only allows me to add to lists.

Any help would be greatly appreciated!

Use Data Jar’sGet Value and give it the key path. It returns whatever is at that key path. If it is a dictionary, it will return that dictionary.

Shortcuts uses an engine behind the scenes that lets it switch between data/object types. If you try out the View Content Graph action you can see the relationships for a variable.

On iOS, tap on a populated variable. And note the Type property. You can change the type to specify or coerce between types.

Here I have added Clipboard as a variable, and perhaps it contains a number or string, but by changing the type, I can tell Shortcuts to treat it as a Boolean.

Hope that helps.

1 Like

THANK YOU SO MUCH STEPHEN!!!

This unlocked a bunch of things for me!!

I really appreciate your help!

:pray: