Developer tools and Service responses

I’ve been looking forward to playing with the new calendar.list_event service and response. I have called the service and obtained the following response:

events:
  - start: "2023-07-10"
    end: "2023-07-11"
    summary: Holiday
  - start: "2023-07-11"
    end: "2023-07-12"
    summary: Office
  - start: "2023-07-12"
    end: "2023-07-13"
    summary: Office

If I want to play with this response in the developer tools (so I can develop a template to process the returned information in some way), what is the best approach?

There is no {% set response = call_service('calendar.list_event', params) %} function. Is there a way to get the above data into a variable with {% set response = ??? %} where ??? is some literal expression for the above data.

Please help.

So, it looks like I can do something like this:

{% set response = ({"events":[
  {"start": "2023-07-07T21:00:00+01:00",
    "end": "2023-07-07T21:01:00+01:00",
    "summary": "Something",
    "description": "Whatever"},
  {"start": "2023-07-08T21:00:00+01:00",
    "end": "2023-07-07T21:01:00+01:00",
    "summary": "Something 2",
    "description": "Whatever 2"}
  ]}) %}

{% for event in response.events %}
{{ event.summary }}
{% endfor %}

But, is there a tool I can use to generate the strucure in the set statement? Doing it by hand is tedious.

Is there a better way?

1 Like

use a yaml to json site
YAML To JSON Converter (convertjson.com)

1 Like

Thanks, @petro , somehow I managed to miss that what was being assigned to the response variable was literal json. Silly me!