Convert output exec command to JSON

Hello All ,
I have use exec.Command(command) on golang and convert it to string. When I RunCommand tasklist on windowOS it return string type . How to convert it to json? i dont understand

This My Code :

Result :

I need this result :
“image_name” : syystem idle proses ,
“PID” : 0 ,
“session_name” : “services”,
“session” : 0 ,
“mem_usage” : “8K”

please help me to resolve this

You will have to iterate over the lines of the result, split it into cells, create a struct with the cells as the values and add the struct to an array. The serialize the array to JSON.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.