Convert JSON logs into an array
Last updated:
You have log files were each line is a string in JSON format and you would like to convert them into an array for further analysis in the CLI, e. g. with a tool lie fx
.
Lets say we have
{"id": 1}{"id": 2}
Then, using sed
in the terminal:
$ sed -e $'1s/^/[\\\n/; $!s/$/,/; $s/$/\\\n]/' c.json[{"id": 1},{"id": 2}]