Issue
I am trying to convert below output into a valid json output. Cant able to solve this using shell scripts.
output
svc pts/0 localhost. Tue Apr 28 21:40 still logged in
svc pts/0 localhost. Tue Apr 28 21:40 - 21:40 (00:00)
svc pts/0 localhost. Tue Apr 28 21:40 - 21:40 (00:00)
...etc
valid json output
{
"Result": [{
"models": ["svc pts 0 localhost.Tue Apr 28 21: 40 still logged in",
"svc pts/0 localhost. Tue Apr 28 21:40 - 21:40 (00:00)"
]
}]
}
is it possible to convert? can someone provide solution.s
Solution
You can use jq like:
program | jq -Rn '{Result:[{models:[inputs]}]}'
program
being the program producing that output.
Answered By - oguz ismail Answer Checked By - Clifford M. (WPSolving Volunteer)