Skip to content

Instantly share code, notes, and snippets.

@ukyo
Created August 8, 2013 14:59
Show Gist options
  • Save ukyo/6185357 to your computer and use it in GitHub Desktop.
Save ukyo/6185357 to your computer and use it in GitHub Desktop.
function parseLTSVLog(text) {
return JSON.parse(
'[' +
text
.trim()
.replace(/([^\t\n\r:]+):([^\t\n\r]*)/g, function(all, k, v) {
return '"' + k + '":' + (v == +v ? v : '"' + v + '"');
})
.replace(/(.+)/g, '{$1}')
.replace(/[\t\n]/g, ',') +
']'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment