Skip to content

Commit 6081802

Browse files
committed
Ejemplos de JSON y Arrays
1 parent f40f16d commit 6081802

File tree

5 files changed

+135
-2
lines changed

5 files changed

+135
-2
lines changed

2023-03-07/arrays.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
let array : number[] = [1, 2, 3, 0.01];

2023-03-07/launch-x.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"fairings": null,
3+
"links": {
4+
"patch": {
5+
"small": "https://images2.imgbox.com/eb/d8/D1Yywp0w_o.png",
6+
"large": "https://images2.imgbox.com/33/2e/k6VE4iYl_o.png"
7+
},
8+
"reddit": {
9+
"campaign": null,
10+
"launch": "https://www.reddit.com/r/spacex/comments/xvm76j/rspacex_crew5_launchcoast_docking_discussion_and/",
11+
"media": null,
12+
"recovery": null
13+
},
14+
"flickr": { "small": [], "original": [] },
15+
"presskit": null,
16+
"webcast": "https://youtu.be/5EwW8ZkArL4",
17+
"youtube_id": "5EwW8ZkArL4",
18+
"article": null,
19+
"wikipedia": "https://en.wikipedia.org/wiki/SpaceX_Crew-5"
20+
},
21+
"static_fire_date_utc": null,
22+
"static_fire_date_unix": null,
23+
"net": false,
24+
"window": null,
25+
"rocket": "5e9d0d95eda69973a809d1ec",
26+
"success": true,
27+
"failures": [],
28+
"details": null,
29+
"crew": [
30+
{ "crew": "62dd7196202306255024d13c", "role": "Commander" },
31+
{ "crew": "62dd71c9202306255024d13d", "role": "Pilot" },
32+
{ "crew": "62dd7210202306255024d13e", "role": "Mission Specialist 1" },
33+
{ "crew": "62dd7253202306255024d13f", "role": "Mission Specialist 2" }
34+
],
35+
"ships": [],
36+
"capsules": ["617c05591bad2c661a6e2909"],
37+
"payloads": ["62dd73ed202306255024d145"],
38+
"launchpad": "5e9e4502f509094188566f88",
39+
"flight_number": 187,
40+
"name": "Crew-5",
41+
"date_utc": "2022-10-05T16:00:00.000Z",
42+
"date_unix": 1664985600,
43+
"date_local": "2022-10-05T12:00:00-04:00",
44+
"date_precision": "hour",
45+
"upcoming": false,
46+
"cores": [
47+
{
48+
"core": "633d9da635a71d1d9c66797b",
49+
"flight": 1,
50+
"gridfins": true,
51+
"legs": true,
52+
"reused": false,
53+
"landing_attempt": true,
54+
"landing_success": true,
55+
"landing_type": "ASDS",
56+
"landpad": "5e9e3033383ecbb9e534e7cc"
57+
}
58+
],
59+
"auto_update": true,
60+
"tbd": false,
61+
"launch_library_id": "f33d5ece-e825-4cd8-809f-1d4c72a2e0d3",
62+
"id": "62dd70d5202306255024d139"
63+
}

2023-03-07/objects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let obj = {
55
a: 1,
66
b: false,
77
c: "hola",
8-
subobj: {
8+
"subobj": {
99
d: null,
10-
e: undefined
10+
e: undefined,
1111
}
1212
};
1313

2023-03-07/person.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"firstName": "James",
3+
"secondName": "Bond",
4+
"age": 28,
5+
"missions": [
6+
"Miami",
7+
"Berlin",
8+
"Acapulco"
9+
]
10+
}

2023-03-07/typed-object.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
type Pos2D = { x: number; y: number };
2+
3+
let pos: Pos2D = {
4+
x: 0.5, // ERROR: fields can be 'x' and 'y' only
5+
y: 0.7,
6+
};
7+
8+
type Person = {
9+
first: string;
10+
last: string;
11+
age?: number; // this field is optional
12+
};
13+
14+
let person: Person = {
15+
first: "James",
16+
last: "Bond",
17+
};
18+
19+
let a = 10;
20+
21+
let obj17 = {
22+
a: 1,
23+
b: true,
24+
c: "hi",
25+
};
26+
27+
interface Cerveza {
28+
name: string;
29+
grado: number;
30+
readonly origin: string;
31+
}
32+
33+
let cerv: Cerveza = {
34+
name: "Voll-Damm",
35+
grado: 7,
36+
origin: "Barcelona",
37+
};
38+
39+
let jsonData1 = `
40+
{
41+
"firstName": "James",
42+
"secondName": "Bond",
43+
"age": 28,
44+
"missions": [
45+
"Miami",
46+
"Berlin",
47+
"Acapulco"
48+
]
49+
}
50+
`;
51+
let jsonData2 = `42`;
52+
53+
let jbond = JSON.parse(jsonData1);
54+
let num = JSON.parse(jsonData2);
55+
console.log(jbond);
56+
console.log(num);
57+
58+
console.log(JSON.stringify(cerv, null, 2));

0 commit comments

Comments
 (0)