I have a text file like this,
Name: john
...some random characters
Title: Dev
...some random characters
Country: Iceland
...some random characters
Name: randy
...
Title: Professor
...
Country: Greenland
...
I am looking for a way to convert this into json like this,
{
Name: john,
Title: Dev,
Country: Iceland
},
{
Name: randy,
Title: Professor,
Country: Greenland
}
There's always one line of extra random characters between each important line.
I am kind of new to bash and having a hard time figuring out how to do this so I was hoping if someone here could help me.
I tried this command but didn't work,
jq -Rs '[ split("\n")[] | select(length > 0) | split(":") | {Name: .[0], Title: .[1], Country: .[2]}]' text.txt