Issue
I have files with similar content but I want to make it a valid JSON I need to add every word of a line in a double quotation mark. I tried existing answers on StackOverflow but none of them works properly.
{container:"proxy",
endpoint:"proxy",
exception:"ApiException"}
transfer to the following format:
{"container":"proxy",
"endpoint":"proxy",
"exception":"ApiException"}
Solution
You may be able to treat each file as a jq
filter that generates an object. For example,
$ cat tmp.jq
{container:"proxy",
endpoint:"proxy",
exception:"ApiException",
instance:"133.3.12.250:9030"}
$ jq -nf tmp.jq
{
"container": "proxy",
"endpoint": "proxy",
"exception": "ApiException",
"instance": "133.3.12.250:9030"
}
Answered By - chepner