How to filter data from ansible json format output for a specific element

Hello All,

I am using API call to fetch some data in json format. I would like to use/filter only part of data for my further tasks. Can someone help me out in filtering the json format for the element ?

API call response data in JSON format:

{“changed”: false, “connection”: “close”, “set_cookie”: “JSESSIONID=B34ADACAE187BBA06C265A478F8565D0; Path=/; Secure; HttpOnly”, “status”: 200}

Debug task:

register: login

  • debug:
    msg: “{{ login.set_cookie }}”

login------- This is the register name which I am using to register the api call response in step1.

Current Output for debug task:

TASK [debug] ************************************************************************************************************
ok: [localhost] => {
“msg”: “JSESSIONID=83FC7E3849EEC229A9999FC4015C0DAB; Path=/; Secure; HttpOnly”
}

Desired Output for debug task:

ok: [localhost] => {
“msg”: “JSESSIONID=83FC7E3849EEC229A9999FC4015C0DAB”
}

Basically I need to get rid of the string after ‘;’ which is “; Path=/; Secure; HttpOnly” from the register output. I am not sure how to filter to get the desired out

{{ login.set_cookie.split(';')[0] }}

That worked. Looks like the syntax is same as python.
Thanks a lot Kai Stian Olstad for your quick response.