Alfred 5.5 is here - Find out what's new

JSON Utility

Use the JSON object to modify the flow of data / variables through an Alfred workflow, along with dynamically modifying the configuration of the attached objects.

JSON Format

The JSON format should be enclosed within an alfredworkflow object, and contain a combination of arg, config or variables.

{
  "alfredworkflow" : {
    "arg" : "{query}",
    "config" : {
    },
    "variables" : {
    }
  }
}

"arg"

The arg field sets the argument passed out of the JSON Utility which is used as the query for the attached objects. Leaving out arg will clear the query, and setting it to {query} will pass through the query. Can be a string to pass a single argument or an array of strings to pass multiple arguments.

"config"

The config object enables dynamic (and overriding) configuration of the workflow objects connected to the output of the JSON Utility.

The easiest way to find out which configuration fields are available for an object is to copy the object configuration from the right-click popup menu for the selected workflow object on the canvas. For example, here is a copied configuration for the Open URL workflow object:

{
  "alfredworkflow" : {
    "config" : {
      "browser" : "",
      "spaces" : "",
      "url" : "{query}",
      "utf8" : true
    }
  }
}

Only the included fields will be overridden, allowing for partial dynamic configuration of a workflow object.

The fields are generally self-explanatory, but if you have trouble identifying a field, set it to a unique value in the object's configuration sheet and copy the configuration again. You'll see the value you set.

"variables"

The variables object enables new variables to be set, and stream variables to be overridden.

Including dynamic placeholders

Fields within the JSON can use dynamic placeholders. Take a look at the Dynamic Placeholders page for more details.

Advanced JSON

Did you know that you can output the above JSON from a Script Action instead of the JSON Utility?

The JSON you see above is native to data passed internally through an Alfred workflow stream, so by creating it within a script and outputting it, you can have full control over the argument, configuration and variables passing through and out of your Script Action.

Latest Blog Post:

Watch Alfred Videos on YouTube

CacheFly Campaign Monitor

"Alfred" is a registered trademark of Running with Crayons Ltd. ©2024 Running with Crayons Ltd. All rights reserved.

Terms & Conditions, Privacy Policy, Cookies.