I've seen a lot of examples to convert a text file to json with jq, but I get stuck on something probably obvious. My input file has this format:
key1: string1
key2: string1
key1: string3
key2: string3
How can I translate that to:
[
{"key1":"string1", "key2": "string2"},
{"key1":"string3", "key2": "string4"}
]
I've tried to use inputs with jq, something like jq -R -n -c '[inputs|split(":")|{(.[0]):.[1]}] | add', but it fails as soon as there's a line break in the file:
jq: error (at result.txt:8): Cannot use null (null) as object key.
Thanks