Jump to content

Questions around using jq (json-parser)


Recommended Posts

Hi, i am building a workflow to start and stop development websites via Local.app, and i am running into a few problems: 

 

1. jq: command not found

When running the workflow, i get the message "jq: command not found", even after adding "source "${HOME}/.zshrc" to my workflow. 

 

2. Wrapping jq output in items: {} 

I don't seem to be able to wrap the jq output in the required parent node "items". (Hope it's ok to ask this question here).

 

i am using within the Script Filter: 

cat "local-site.json" | jq -j  '.[] | {uid: .id, title: .name, subtitle:.path}'

which gives me: 

  {
    "uid": "0pbbVr2HP",
    "title": "dev-site-1",
    "subtitle": "/path"
  }{
    "uid": "RK_9dUG-J",
    "title": "dev-site-2",
    "subtitle": "/path-2"
  }

 

what Alfred expects: 

{"items": [
  {
    "uid": "0pbbVr2HP",
    "title": "dev-site-1",
    "subtitle": "/path"
  }{
    "uid": "RK_9dUG-J",
    "title": "dev-site-2",
    "subtitle": "/path-2"
  }
]}


Thanks in advance! 

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...