Created
October 21, 2014 03:25
-
-
Save JArmando/586fee20dbc9c836aace to your computer and use it in GitHub Desktop.
#DevDo como crear un json a partir de texto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var texto = '1 Pablo Batida 2 soy una prueba'; | |
var listaBonita = texto.split(/\d/g); | |
var jsonsito = ''; | |
listaBonita.map(function(element, index){ | |
jsonsito += element ? '{"'+ index + '":"' + element + '"}':'' | |
}); | |
console.log(jsonsito); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
si... se puede hacer en dos lineas, pero para que los no iniciados tengan una idea de que esta sucediendo ahi...