title: Python YAML to JSON to YAML
body: <p>I'm new to python so I am building a simple program to parse YAML to JSON and JSON to YAML. </p>
  
  <p>The <code>yaml2json</code> converts YAML to JSON on a single line, but a JSON validator says it is correct.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>def parseyaml(inFileType, outFileType):
     infile = input('Please enter a {} filename to parse: '.format(inFileType))
     outfile = input('Please enter a {} filename to output: '.format(outFileType))
  
     with open(infile, 'r') as stream:
         try:
             datamap = yaml.safe_load(stream)
             with open(outfile, 'w') as output:
                 json.dump(datamap, output)
         except yaml.YAMLError as exc:
             print(exc)
  
      print('Your file has been parsed.\n\n')
  
  
  def parsejson(inFileType, outFileType):
     infile = input('Please enter a {} filename to parse: '.format(inFileType))
     outfile = input('Please enter a {} filename to output: '.format(outFileType))
  
     with open(infile, 'r') as stream:
         try:
             datamap = json.load(stream)
             with open(outfile, 'w') as output:
                 yaml.dump(datamap, output)
         except yaml.YAMLError as exc:
             print(exc)
  
     print('Your file has been parsed.\n\n')
  </code></pre>
  
  <p>An example of the original YAML vs. the new YAML</p>
  
  <p>Original:</p>
  
  <pre><code>inputs:
    webTierCpu:
      type: integer
      minimum: 2
      default: 2
      maximum: 5
      title: Web Server CPU Count
      description: The number of CPUs for the Web nodes
  </code></pre>
  
  <p>New:</p>
  
  <pre><code>inputs:
    dbTierCpu: {default: 2, description: The number of CPUs for the DB node, maximum: 5,
      minimum: 2, title: DB Server CPU Count, type: integer}
  </code></pre>
  
  <p>It doesn't look like its decoding all of the JSON so I'm not sure where I should go next...</p>