I am looking to transform a set of rows that are key value (space seperated) to JSON. I am hoping to use jq-1.5 for this:
local.location.altitude 3.0
local.location.latitude 40.025495
local.location.longitude -74.312501
local.orientation.pitch 0.0
local.orientation.roll 0.0
local.orientation.yaw 0.0
local.velocity.azimuth 0.0
local.velocity.elevation 0.0
local.velocity.magnitude 0.0
To
{
"local.location.altitude": "3.0",
"local.location.latitude": "40.025495",
"local.location.longitude": "-74.312501",
"local.orientation.pitch": "0.0",
"local.orientation.roll": "0.0",
"local.orientation.yaw": "0.0",
"local.velocity.azimuth": "0.0",
"local.velocity.elevation": "0.0",
"local.velocity.magnitude": "0.0"
}
I am trying commands like:
./get-data | jq -R 'splits("\\s+")'
./get-data | jq -R 'splits("\\s+")|{ a : .[0], b : .[1] }
But unable to make it work. I feel I am close. Anyone know how to go from {{key}} {{val}} to {"key": "value"}?