I have historical data that I need to process but cannot recreate. The problem I'm having is that there are no quotes around the identifiers so it can't be parsed using JSON.parse(data)
.
Here's some sample data:
[2013-10-04 12:14:39.987] [INFO] clientOut - broadcast: 97e27acf-0f4d-4021-a3a9-7e301e22ad59 #000006425 vehicle telemetry: { speed: 0.13,
velocity: { x: 0, y: 0, z: 0 },
attitude:
{ pitch: 3.309539134025706,
roll: 6.72947632315362,
yaw: 136.35147621231474,
x: 3.309539134025706,
y: 6.72947632315362,
z: 136.35147621231474 },
altitude: 7.023,
temperature: 0,
heading: 136.35147621231474,
counter: '000006425' }
The above entry was created via log4js in node.js. I can pull out the JSON-like data, but it's still not valid. I need it to look like this:
{ "speed": 0.13,
"velocity": { "x": 0, "y": 0, "z": 0 },
"attitude":
{ "pitch": 3.309539134025706,
"roll": 6.72947632315362,
"yaw": 136.35147621231474,
"x": 3.309539134025706,
"y": 6.72947632315362,
"z": 136.35147621231474 },
"altitude": 7.023,
"temperature": 0,
"heading": 136.35147621231474,
"counter": "000006425" }
How can I do this? Is there an easy approach to apply quotes to each identifier?