Skip to content

Instantly share code, notes, and snippets.

@osoda
Last active August 29, 2018 16:00
Show Gist options
  • Save osoda/fd61c7854ff34446b26ec00ed4117d76 to your computer and use it in GitHub Desktop.
Save osoda/fd61c7854ff34446b26ec00ed4117d76 to your computer and use it in GitHub Desktop.
Transform the result select sql that show the GUI (MySQL Workbench)
String.prototype.SelectToJSON = function(){
var str = '['+this.split('\n').map((el)=>{return '{'+el.split(', ').
map((e,i)=>{return `"${i}": ${e.replace(/'/gi, '"')}`})+'},'}).join('\n').slice(0,-1)+']'
return JSON.parse(str)
}
// Result shown by Gui And Copy whit the option 'Copy Row'
var result = `'6', 'PAULA ', '2018-01-30', ' KEVIN', '', '0', '', '', 'SASA1', '2'
'7', 'BRANDON ', '2018-01-30', 'ALBLO', '', '0', '', '', 'SASA1', '3'
'8', 'PILAR', '2018-01-30', 'CACERES', '', '0', '', '', 'SASA1', '4'`
objJson = result.SelectToJSON()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment