YAML validate
pip3 install pyyaml
CODE:
#!/usr/bin/env python
import yaml
import json
with open("blueprint.yaml", 'r') as stream:
try:
yaml.load(stream, Loader=yaml.FullLoader)
print("YAML is good")
except yaml.YAMLError as exc:
print(exc)
print("YAML is bad")
with open("inputs.json") as f:
try:
json.load(f)
print("JSON is good")
except ValueError as exc:
print("JSON is bad")
OUTPUT:
/Users/linda/PycharmProjects/hello/venv/bin/python /Users/linda/PycharmProjects/hello/yaml_json.py
YAML is good
JSON is bad
Process finished with exit code 0