I have file containing Multiple JSON Objects and need to covert them to JSON. I have bash and Excel installed, but cannot install any other tool.
{"name": "a","age":"17"}
{"name":"b","age":"18"}
To:
[{"name": "a","age":"17"},
{"name":"b","age":"18"}]
Assumptions:
Sample input:
One
awkidea:Where:
printfthe line without a terminating linefeedpfx) of[pfx) is set to,\n(ie, terminate the previous line with,\n)printf "]\n"This generates:
Making sure @chepner's comment (re: a
sedsolution) isn't lost in the mix:This generates:
NOTE: I can remove this if @chepner wants to post this as an answer.