Very basic Dictionary/JSON question (v11)

The word ‘dictionary’ turns up in different contexts.

JSON, like .plist XML, provides two forms of composite data structuring:

  • Arrays for indexed sequence
  • Dictionaries (sometimes called ‘Objects’, in a JS context) for discrete clustering of key-value pairs.

( In Python documentation they keep more narrowly to the term dictionary, and “object” is heard more rarely )

You can write JSON dictionary data to a KM Dictionary:

https://wiki.keyboardmaestro.com/action/Set_Dictionary_to_JSON

To quote the wiki entry above:

The Set Dictionary to JSON (v9.0+) action lets you set a Keyboard Maestro dictionary from a JSON dictionary.

and you also have a %JSONFromDictionary% token

but these two kinds of dictionary, while partially[1] isomorphic, are far from identical.

  • Keyboard Maestro dictionaries consist of record clusters in an sqlite3 database table, which you could query in patterns like SELECT dictionary, key, value FROM dictionaries
  • JSON, is of course, just a canonical stringification of JavaScript data structures.

  1. Partially – KM dictionary values are always atomic – strings or numbers – whereas in JSON dictionaries, the value of a key can itself be an Array or Dictionary. The depth of nesting is not constrained. ↩︎

1 Like