Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save doesitblend/6e63caf909235c4875bbf38b172b382f to your computer and use it in GitHub Desktop.
Save doesitblend/6e63caf909235c4875bbf38b172b382f to your computer and use it in GitHub Desktop.
json_yaml_converter.py
#!/opt/saltstack/salt/bin/python3.10
# This script was generated with ChatGPT
import sys
import json
import yaml
def main():
try:
# Read JSON data from STDIN
input_data = sys.stdin.read()
# Parse JSON data
json_data = json.loads(input_data)
# Convert JSON to YAML
yaml_data = yaml.dump(json_data, default_flow_style=False)
# Output YAML data to STDOUT
sys.stdout.write(yaml_data)
except Exception as e:
# Output errors to STDERR
sys.stderr.write(str(e) + "\n")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment