Last active
December 24, 2018 05:59
-
-
Save parzibyte/5033e79b8d1b06aad058ff07a59267ee to your computer and use it in GitHub Desktop.
JSON.stringify en JavaScript created by parzibyte - https://repl.it/@parzibyte/JSONstringify-en-JavaScript
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
/* | |
Demostrar codificación de JSON en JavaScript | |
@author parzibyte | |
*/ | |
// Datos primitivos | |
let nombre = "Luis", | |
edad = 50, | |
mayorDeEdad = true; | |
console.log(JSON.stringify(nombre)); // "Luis" | |
console.log(JSON.stringify(edad)); // 50 | |
console.log(JSON.stringify(mayorDeEdad)); // true | |
// Algo complejos | |
let libros = ["¿Sueñan los androides con ovejas eléctricas?", "El Jilguero", "El resplandor", "La rebelión de Atlas"]; | |
console.log(JSON.stringify(libros)); | |
//["¿Sueñan los androides con ovejas eléctricas?","El Jilguero","El resplandor","La rebelión de Atlas"] | |
let mascota = { | |
nombre: "Guayaba", | |
edad: 1, | |
amigos: [{ | |
nombre: "Maggie", | |
edad: 2 | |
}, { | |
nombre: "Bichi", | |
edad: 1 | |
}] | |
}; | |
console.log(JSON.stringify(mascota)); | |
//{"nombre":"Guayaba","edad":1,"amigos":[{"nombre":"Maggie","edad":2},{"nombre":"Bichi","edad":1}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment