Table of contents
- ๐ถ Reading JSON and YAML in Python
- ๐ถ Tasks-1: Create a Dictionary in Python and write it to a JSON File.
- ๐ถ Tasks-2: Read a JSON file services.json kept in this folder and print the service names of every cloud service provider.
- ๐ถ Tasks-3: Read the YAML file using Python, file services.yaml and read the contents to convert yaml to json
๐ถ 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 libraries one should use in Python for DevOps.
Python has numerous libraries like
os
,sys
,json
,yaml
etc that a DevOps Engineer uses in day-to-day tasks.
๐ถ Tasks-1: Create a Dictionary in Python and write it to a JSON File.
json.dump() - convert a Python object into an equivalent JSON object and store the result into a JSON file in the working directory.
๐ถ Tasks-2: 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
json.loads()- It is used to parse a valid JSON string and convert it into a Python Dictionary.
๐ถ Tasks-3: Read the YAML file using Python, file services.yaml
and read the contents to convert yaml to json
Stay in the loop with my latest insights and articles on cloud โ๏ธ and DevOps โพ๏ธ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
GitHub Repo for the above task git@github.com:Chandreshpatle28/python_practice.git
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.
#Git #Linux Devops #Devopscommunity #90daysofdevopschallenge #python