forked from jonmircha/youtube-js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
06_json.html
60 lines (52 loc) · 1.87 KB
/
06_json.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON JavaScript Object Notation</title>
</head>
<body>
<h1>JSON JavaScript Object Notation</h1>
<script>
/* ********** Curso JavaScript: 59. JSON - #jonmircha ********** */
/* https://www.json.org/json-es.html */
/* https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/JSON */
const json = {
cadena: "Jon",
numero: 35,
booleano: true,
arreglo: ["correr", "programar", "cocinar"],
objeto: {
twitter: "@jonmircha",
email: "[email protected]"
},
nulo: null
}
console.log(json);
console.log(JSON);
console.log("*** JSON.parse ***");
console.log(JSON.parse("{}"));
console.log(JSON.parse("[1,2,3]"));
console.log(JSON.parse("true"));
console.log(JSON.parse("false"));
console.log(JSON.parse("19"));
console.log(JSON.parse('"Hola Mundo"'));
console.log(JSON.parse("null"));
//console.log(JSON.parse("undefined"));
console.log(JSON.parse('{ "x": 2, "y": 3 }'));
console.log("*** JSON.stringify ***");
console.log(JSON.stringify({}));
console.log(JSON.stringify([1, 2, 3]));
console.log(JSON.stringify(true));
console.log(JSON.stringify(false));
console.log(JSON.stringify(19));
console.log(JSON.stringify("Hola Mundo"));
console.log(JSON.stringify(null));
console.log(JSON.stringify(undefined));
console.log(JSON.stringify({ x: 2, y: 3 }));
console.log("*** Ejemplo JSON ***");
console.log(JSON.stringify(json));
console.log(JSON.parse('{"cadena": "Jon","numero": 35, "booleano": true,"arreglo": ["correr","programar","cocinar"],"objeto": {"twitter": "@jonmircha","email": "[email protected]"},"nulo": null}'));
</script>
</body>
</html>