Skip to content

Commit 651d9cf

Browse files
committed
v0.2.5
1 parent 832c4b1 commit 651d9cf

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Welcome Pragmatic_JavaScript [[v0.2.4]](https://github.com/Zelechos/Pragmatic_JavaScript/releases/tag/v0.2.3) !!!
1+
# Welcome Pragmatic_JavaScript [[v0.2.5]](https://github.com/Zelechos/Pragmatic_JavaScript/releases/tag/v0.2.3) !!!
22
<img align="center" src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif" alt="javascript" width="1000"/>
33

44
![ezgif com-gif-maker](https://miro.medium.com/max/3200/1*OF0xEMkWBv-69zvmNs6RDQ.gif)

Vanilla JavaScript/JSON/data.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"cadena": "Alex",
3+
"numero": 99,
4+
"booleano": true,
5+
"arreglo": ["uno", "dos", "tres"],
6+
"objeto":{
7+
"twitter": "@CoderPragmatic",
8+
"email": "[email protected]"
9+
},
10+
"nulo": "null"
11+
}

Vanilla JavaScript/JSON/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>JSON javascript object notation</title>
8+
<script type="text/javascript" src="./jsonObjetoGenerico.js"></script>
9+
</head>
10+
<body>
11+
<style>
12+
body{
13+
background-color: #000;
14+
color: white;
15+
}
16+
</style>
17+
<h1>
18+
JSON javascript object notation
19+
</h1>
20+
</body>
21+
</html>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
'use strict';
2+
3+
// creamos un objeto generico en javascript
4+
const json = {
5+
cadena: "Alex",
6+
numero: 99,
7+
booleano: true,
8+
arreglo: ["uno", "dos", "tres"],
9+
objeto:{
10+
twitter: "@CoderPragmatic",
11+
12+
},
13+
nulo: null
14+
}
15+
16+
console.log(json);
17+
18+
// Ejemplos de como consumir nuestro archivo JSON
19+
console.log(JSON);
20+
21+
// JSON.parse() Analiza una cadena de texto como JSON y lo convierte a un valor valido en js
22+
console.warn(`------------ usando el metodo parse() ---------------------`);
23+
24+
// esto no son simples llaves esto gracias al metodo parse se reconoce como un objeto
25+
console.log(JSON.parse("{}"));
26+
27+
// de igual manera con un array
28+
console.log(JSON.parse("[1, 2, 3]"));
29+
30+
// y lo mismo con los diferentes tipos de datos
31+
console.log(JSON.parse("false"));
32+
console.log(JSON.parse("29"));
33+
// console.log(JSON.parse("'Hello World'"));
34+
console.log(JSON.parse("null"));
35+
// console.log(JSON.parse("undefined"));
36+
37+
38+
// JSON.stringify() Convierte un objeto o valor de JS en una cadena de texto JSON
39+
console.warn(`------------ usando el metodo stringify() ---------------------`);
40+
41+
console.log(JSON.stringify({}));
42+
console.log(JSON.stringify([1, 2, 3]));
43+
console.log(JSON.stringify(false));
44+
console.log(JSON.stringify(null));
45+
console.log(JSON.stringify(99));
46+
console.log(JSON.stringify(undefined));
47+
console.log(JSON.stringify({x:2,y:4}));
48+
console.log(JSON.stringify(json));
49+
50+
// de JSON a objeto de javascript
51+
console.log(JSON.parse('{"cadena":"Alex","numero":99,"booleano":true,"arreglo":["uno","dos","tres"],"objeto":{"twitter":"@CoderPragmatic","email":"[email protected]"},"nulo":null}'));
52+
53+
54+
55+

0 commit comments

Comments
 (0)