I am trying to convert a file containing key = value pairs into JSON.This file might contain Windows EOL (\r\n) and empty lines.
Given the following input (mind the empty lines):
foo = aabar = bbqux = ccwhite space = white space* = special-charThis is the expected result:
{"foo": "aa","bar": "bb","qux": "cc","white space": "white space","*": "special-char"}I managed to go this far:
{"foo": "aa"}{"bar": "bb"}{"qux": "cc"}{"white space": "white space"}{"*": "special-char"}Using the following command:
jq --raw-input 'split("\n") | map(split(" = ") | { (.[0]): .[1] }) | .[]'But I can not figure out the missing bit. What is missing or is this a better way to achieve this?
Edit: added constraint about empty line and Windows EOL