How to capture/filter stdout_lines

Stdout_lines that I get contains strings , json in different lines.

I want to capture the last line and copy those contents to a a new Json file.

How do I capture the last line from the registered variable.

I tried this and it didn't work.

"{{ Regvar.stdout_lines | last }}"

Try

{{ regvar.stdout_lines[-1] }}