Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active December 24, 2018 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5033e79b8d1b06aad058ff07a59267ee to your computer and use it in GitHub Desktop.
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
/*
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