WEBVTT

1
00:00.000 --> 00:04.440
Now in the previous video we discussed how we could create key value pairs in Y

2
00:04.440 --> 00:05.040
AML,

3
00:05.040 --> 00:09.050
now what I want to do is to talk to you about something known as a raise. So

4
00:09.050 --> 00:09.680
with that said,

5
00:09.680 --> 00:13.920
let's get to it. So once again if you go to one of the online tools to validate

6
00:13.920 --> 00:14.800
your YAML,

7
00:14.800 --> 00:18.000
what I'm going to do is attempt to write some YAML but there's going to be a

8
00:18.000 --> 00:18.800
bit of a problem.

9
00:18.800 --> 00:22.250
Let's see what happens. So I'll start off with my three hyphens for good

10
00:22.250 --> 00:22.800
practice.

11
00:22.800 --> 00:26.750
And let's maybe say I want to have a name key and the name can just be John Mc

12
00:26.750 --> 00:27.200
Govern.

13
00:27.200 --> 00:32.240
Then I happen to have my age, specify 38. And let's maybe say I want to specify
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:27.200 --> 00:32.240
Then I happen to have my age, specify 38. And let's maybe say I want to specify

14
00:32.240 --> 00:32.800
the foods that

15
00:32.800 --> 00:36.790
I like. So I say foods and then I maybe have the value pizza and I try to add

16
00:36.790 --> 00:38.080
in more foods, okay.

17
00:38.080 --> 00:42.480
Let's maybe say sushi but there is a bit of a problem. If I go and I click go

18
00:42.480 --> 00:43.040
here,

19
00:43.040 --> 00:48.050
here's us here that map keys must be unique and we actually have a problem at

20
00:48.050 --> 00:49.280
line five which is

21
00:49.280 --> 00:53.500
this part right here. This is where we have a duplication in the keys

22
00:53.500 --> 00:55.200
themselves. So this is

23
00:55.200 --> 01:00.240
a new discovery. Our keys in YAML must actually be unique at least at the same
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

23
00:55.200 --> 01:00.240
a new discovery. Our keys in YAML must actually be unique at least at the same

24
01:00.240 --> 01:01.680
level of indentation.

25
01:01.680 --> 01:05.850
So the question is what if we have multiple values we want to specify say for

26
01:05.850 --> 01:06.960
example we have

27
01:06.960 --> 01:11.160
multiple favorite foods or multiple servers that type of thing. We can't just

28
01:11.160 --> 01:11.920
keep duplicating

29
01:11.920 --> 01:16.860
the key itself. So how will we solve this particular problem? Well the answer

30
01:16.860 --> 01:18.160
is by creating something

31
01:18.160 --> 01:22.840
known as an array. Sometimes colloquially this might be referred to as a list

32
01:22.840 --> 01:23.360
object

33
01:23.360 --> 01:27.070
but the correct terminology with respect to YAML is indeed an array. Now what

34
01:27.070 --> 01:27.840
an array is going to

35
01:27.840 --> 01:32.290
do is going to allow us to specify multiple values. Now one thing to note is
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:27.840 --> 01:32.290
do is going to allow us to specify multiple values. Now one thing to note is

36
01:32.290 --> 01:33.360
that we can actually

37
01:33.360 --> 01:37.380
denote this in two different ways. We can use something known as the inline

38
01:37.380 --> 01:38.240
syntax. This is going

39
01:38.240 --> 01:43.580
to make use of square brackets and we can also use something known as the block

40
01:43.580 --> 01:44.480
format syntax.

41
01:44.480 --> 01:48.800
This is basically going to make use of hyphens. Now there is no right or wrong

42
01:48.800 --> 01:49.840
way in which to do

43
01:49.840 --> 01:53.790
this both types of syntax is absolutely valid but the more common one you're

44
01:53.790 --> 01:55.120
going to see is indeed

45
01:55.120 --> 02:00.030
the block format utilizing the hyphens. But I'll show you both just in case. So
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:55.120 --> 02:00.030
the block format utilizing the hyphens. But I'll show you both just in case. So

46
02:00.030 --> 02:00.880
let's maybe say we

47
02:00.880 --> 02:05.130
have a whole bunch of food that we want to represent. We could just have a food

48
02:05.130 --> 02:06.240
key and as opposed to

49
02:06.240 --> 02:10.690
having the value here as pizza we could try say for example the inline format

50
02:10.690 --> 02:11.680
in fact let me just

51
02:11.680 --> 02:15.060
zoom in a little bit here. So in fact let's first start with the block format

52
02:15.060 --> 02:15.840
because that is the

53
02:15.840 --> 02:20.020
most common. So indented within foods because it's going to belong to the foods

54
02:20.020 --> 02:21.120
I'm going to say

55
02:21.120 --> 02:24.970
one two for the spacing and then I'm going to have a hyphen and then after that

56
02:24.970 --> 02:25.840
hyphen I can

57
02:25.840 --> 02:30.930
specify the actual value that I want to add in here so I can say pizza if I hit
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

57
02:25.840 --> 02:30.930
specify the actual value that I want to add in here so I can say pizza if I hit

58
02:30.930 --> 02:31.920
enter and I do

59
02:31.920 --> 02:36.080
space space and hyphen again I can add in my second value which would be sushi

60
02:36.080 --> 02:36.800
and again I

61
02:36.800 --> 02:40.430
can add in another value let's maybe say carrots carrots are not my favorite

62
02:40.430 --> 02:41.280
food by the way I'm

63
02:41.280 --> 02:46.530
just adding in some new values and if I get down here and click go notice this

64
02:46.530 --> 02:47.680
is valid yaml and

65
02:47.680 --> 02:52.190
we can see here visually that these three values because of the indentation

66
02:52.190 --> 02:53.600
here they actually belong

67
02:53.600 --> 02:58.790
to the food key that in the food folder so to speak. Now like I say we can also

68
02:58.790 --> 02:59.680
do this using the

69
02:59.680 --> 03:04.010
inline formatting or the inline syntax let's just delete this and the way we do
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

69
02:59.680 --> 03:04.010
inline formatting or the inline syntax let's just delete this and the way we do

70
03:04.010 --> 03:05.280
this is by simply

71
03:05.280 --> 03:09.140
using square brackets so if we do square brackets here we can just specify all

72
03:09.140 --> 03:10.080
of the values that

73
03:10.080 --> 03:14.900
we want and we separate those values out utilizing commas so I could just say

74
03:14.900 --> 03:15.760
pizza and then a

75
03:15.760 --> 03:20.460
comma and then add in sushi and then a comma and then again I can add in

76
03:20.460 --> 03:22.240
carrots and I hit go right

77
03:22.240 --> 03:26.700
here automatically you'll notice that this particular program has accepted this

78
03:26.700 --> 03:28.000
is valid yaml but it

79
03:28.000 --> 03:32.850
did actually format it using the block format indentation nevertheless both
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

79
03:28.000 --> 03:32.850
did actually format it using the block format indentation nevertheless both

80
03:32.850 --> 03:34.000
ways are absolutely

81
03:34.000 --> 03:39.560
valid so in combination with these key values as well as these array objects

82
03:39.560 --> 03:39.920
you can really

83
03:39.920 --> 03:44.160
create some very complex and nested data so let's say I wanted to represent all

84
03:44.160 --> 03:45.120
of the users on my

85
03:45.120 --> 03:49.180
system now if I happen to have multiple users I would want to have my hyphen to

86
03:49.180 --> 03:50.160
denote multiple

87
03:50.160 --> 03:54.430
objects and I could give that user a name so let's say the name is samona and

88
03:54.430 --> 03:55.840
the next user can be

89
03:55.840 --> 04:00.080
lalo now maybe we want to add in the user ID for that particular user so let's
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

89
03:55.840 --> 04:00.080
lalo now maybe we want to add in the user ID for that particular user so let's

90
04:00.080 --> 04:00.560
maybe say

91
04:00.560 --> 04:05.500
a one thousand and one for samona and similar for lalo we can have one thousand

92
04:05.500 --> 04:06.720
and two so now let's

93
04:06.720 --> 04:10.400
say the next thing that we want to represent where all of the groups that these

94
04:10.400 --> 04:11.440
users happen to be a

95
04:11.440 --> 04:15.560
member of now this is going to comprise of multiple entries so what I could do

96
04:15.560 --> 04:16.640
is I could create a

97
04:16.640 --> 04:21.220
group's key right here and again and then to within I could have my hyphens so

98
04:21.220 --> 04:22.560
I can say samona is part

99
04:22.560 --> 04:26.420
of the samona primary group and let's imagine samona is part of the view group

100
04:26.420 --> 04:27.200
and let's say

101
04:27.200 --> 04:31.960
samona is also part of the engineering team similarly with lalo we can have
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

101
04:27.200 --> 04:31.960
samona is also part of the engineering team similarly with lalo we can have

102
04:31.960 --> 04:32.800
groups and in

103
04:32.800 --> 04:37.320
within lalo can be part of the lalo primary group and let's say lalo is not a

104
04:37.320 --> 04:38.640
member of the view group

105
04:38.640 --> 04:43.600
but lalo is a member of the design team notice that via the use of my hyphen

106
04:43.600 --> 04:44.720
ation I'm able to

107
04:44.720 --> 04:48.220
effectively duplicate say for example the name key here and the name key here

108
04:48.220 --> 04:48.960
because they're

109
04:48.960 --> 04:53.790
part of an array and similarly nested within those we can further use those

110
04:53.790 --> 04:55.200
array objects in this

111
04:55.200 --> 05:00.060
case here to signify multiple different values for the groups key so let's try
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

111
04:55.200 --> 05:00.060
case here to signify multiple different values for the groups key so let's try

112
05:00.060 --> 05:01.120
the validation

113
05:01.120 --> 05:05.120
We click go as we can see here this indeed is valid yamel.
