## Convert stdout_lines into json format ##

Hi Team,
Greetings of the day!!!

Is there any module or plugin available through which we can convert the stdout_lines of a win_shell output into json data.
if it is available can you help me how to use it.

Below is my powershell command output coming in ansible result.

“stdout_lines”: [
“”,
" Id ProcessName CPU",
" – ----------- —",
“564 lsass 83.46875”,
“876 svchost 82.484375”,
“”,
“”
]

Expecting output like below format:

“stdout_lines”:
{
“Id”: 564**,**
“ProcessName”: “lsass”,
“CPU”: 83.46875
},
{
“Id”: 876**,**
“ProcessName”: “svchost”,
“CPU”: 82.484375
}

so that I can fetch the id or process names like stdout_lines.ProcessName

In your win_shell command add “| ConvertTo-Json” to the end. That will pipe the output into a json string which you can then use the from_json filter in Ansible to turn it into a dict.