macaroni

json

Description:
The json executor parses a json string, making typical json expressions available via resolvers

Parent: execute, then, else Value (simple form): : string specifying json content to be parsed
Value (key/value form):

# simple form
- json: (string)

# simple example
- json: '{http.response}'

# key/value form w/scalar
- json: (string, required)
  path: (string, optional)
  output: (string, optional)

# key/value example w/scalar
- json: '{http.response}'
  path: 'user_id'
  output: 'userId'

# key/value form w/object
- json: 
    data: (string, required)
    path: (string, optional)
    output: (string, optional)

# key/value example w/object
- json:
    data: '{http.response}'
    path: 'user_id'
    output: 'userId'

EXAMPLE:

# get the current weather forecast
commands:
- triggers:
  - what's the weather
  execute:
  - http: 'https://api.msn.com/weather/current?apikey={apiKey}&ocid=msftweather&appId={appId}&wrapodata=false&locale=en&lat={lat}&lon={lon}&units={units}'
  - json: '{http.response}'
  - speak:  |
      It's currently {responses[0].weather[0].current.cap} and {responses[0].weather[0].current.temp} degrees in {responses[0].source.location.Name}

Status: ✅ IMPLEMENTED