## YAML 이해하기
- 키와 값의 쌍
- 문자, 숫자 설정 가능
- True, False 설정 가능
- 목록 (List), 배열 (Array) 설정 가능
- 주석 (#) 허용 - JSON 은 주석 불가
- JSON 변환시 -----> List 도 Array 로 변경됨
person:
name: John
age: 29
isMale: true
stuff:
- laptop
- car
- bike
food: [pizza, donuts, coke]
friends:
- name: Jane
age: 19
- name: mike
age: 22
{
"person": {
"name": "John",
"age": 29,
"isMale": true,
"stuff": [
"laptop",
"car",
"bike"
],
"food": [
"pizza",
"donuts",
"coke"
],
"friends": [
{
"name": "Jane",
"age": 19
},
{
"name": "mike",
"age": 22
}
]
}
}
## YAML -> JSON 변환
## YAML 변환기
https://codebeautify.org/yaml-to-json-xml-csv
==========================================
Now that you already have some experience writing Gamwell files and defining pipelines in your legacy.
I wanted to go back to the basics of Yamal and what is Yamal anyway.
If we look at Yamal in a very, very simple way, we can say that Yamal is just a key value combination.
So a key value pair.
So, for example, if I define a key code name, I can assign the name John.
So name will be like the variable, the key, and John will be a string and will hold that value and
we can use the to store strings, but we can also use Yamal to store integers, for example.
So if we say age is 29.
Now, this is a new property and it says that John is 29.
The same goes with booleans.
So if you want to say something like mail or e-mail.
This will be true.
Great, apart from that, a very powerful feature in Yamal is the possibility of creating lists or arrays
of multiple items.
So, for example, if we see here stuff.
Let's see what kind of stuff John John has.
So let's type here some stuff like laptop.
That's right here, car and bike, OK, now.
Stuff is the property and now laptop car bikes are all items in a list, so we have here a list of items
or an array, as you prefer to call it.
And we can write it like this, but we can also write lists in this way.
So freeride what kind of food John likes?
We can also writing letters.
Between square brackets.
We can write Petar.
Dunnarts and maybe coke, so this is another way we can write this this way of writing is totally similar
with this one.
If you're writing strength, you can also put in between double quotes.
And that will work as well, but I think it's much more readable if you don't really write really complex
things that you will write them this way.
Now, let's go ahead and put everything within an object so we if we make it like that here person.
And you make here an indentation.
All these properties that we have created so far because they are indented under person, it will be
children of the person object.
So the person will have a property called name A property called H.
Male and so on, so you can see that indentation actually shows us which property belongs to which object.
Additionally, nothing stops us from adding other objects within an existing object.
So, for example, if we say here, friend.
Let's go ahead to create a list of Frente.
And.
A friend can be Jane.
And she may be 19.
Not a friend can be, Mike.
And Mike is 22 now, what have done here, I have again, a list.
Friends and now I don't have a list of strings, actually, now I have a list of object.
So that's about it.
You need to pay attention to indentation and to see how everything is listed, but apart from that,
I think Yamal is pretty easy to understand.
Sooner or later, you would want to write a comment or to explain something, or maybe you want to disable
something, I don't know if you want to write a comment, you can do it by using no sign.
Like this, this is a comment and you will see that in my idy, this has a different color and his and
has been marked as a comment.
There's an important distinction here because Yamal is pretty similar to Jason actually can transform
Yamal in Jason.
Jason doesn't allow comments, but Yamal does.
So I think this is a very important feature.
But if you are more familiar with Jason and you're still not sure this indentation exactly how it works,
but Jason is something that you have worked in the past and you're familiar with from APIs or from anything
else, they are online converters that can take Yamal and convert it to Jason.
Just to give you this understanding on exactly what is everything?
How does this configuration actually work like?
So what I'm going to doing on a simply copied is.
And I met this online Yamal convertor, and you'll find a link as a resource to this lecture.
I'm going to simply paste this configuration here and I'm going to click here, Yamal, to Jason.
Now, as soon as I have done this, you will see here that this takes the shape.
Now, I have a person as a property to an object.
And again, this property is again an object on its own and it has different properties and you will
see here that stuff is in the array.
Food is an array as well.
PERENT is an array of objects.
And yeah, hopefully this will give you a better understanding.
Now, the idea, again, of the Yamal is to make it easier to read.
I think in the beginning, it takes a bit of practice to get used to YAML and only after writing YAML
on your own, you can really get a feeling if it's easier to write or not.
But if you have written Jason in the past, you'll probably be happy not to write so many quotes and
this will be a much nicer format to work with.
'[AWS] > GITLAB' 카테고리의 다른 글
45장. Anchors (0) | 2022.02.21 |
---|---|
44. 작업 비활성화 (0) | 2022.02.21 |
42장. YAML Overview (0) | 2022.02.21 |
41장. 요약 및 결론 (0) | 2022.02.21 |
40장. before_script 및 after_script 구성 (0) | 2022.02.21 |
댓글