Reading JSON and YAML in Python
As a DevOps Engineer you should be able to parse files, be it txt, json, yaml, etc.
You should know what all libraries one should use in Pythonfor DevOps.
Python has numerous libraries like
os
,sys
,json
,yaml
etc that a DevOps Engineer uses in day to day tasks.Create a Dictionary in Python and write it to a json File.
Read a json file services.json
kept in this folder and print the service names of every cloud service provider.
output
aws : ec2
azure : VM
gcp : compute engine
Read YAML file using python, file services.yaml
and read the contents to convert yaml to json
Rules for Creating YAML file
When you are creating a file in YAML, you should remember the following basic rules −
YAML is case sensitive
The files should have .yaml as the extension
YAML does not allow the use of tabs while creating YAML files; spaces are allowed instead
Thank you for reading!! Hope you find this helpful.
#day15#90daysofdevops#devopscommunity
Always open for suggestions..!!
Thank you Shubham Londhe.