title: python Jinja2 creating a file from json template using yaml conf
body: <p>I am writing a function to render json template using yaml config file.</p>
  
  <p>It looks something like below :</p>
  
  <p><code>render.py</code>:</p>
  
  <pre><code>if len(sys.argv) != 3:
      print "usage: python render_template.py [yaml_file] [jinja_template_file]"
      sys.exit(1)
  
  with open(sys.argv[1], "r") as stream:
      config = yaml.safe_load(stream)
  with open(sys.argv[2], "r") as stream:
      template_text = stream.read()
  template = Template(template_text)
  
  print template.render(config)
  </code></pre>
  
  <p><code>test.yaml</code>:</p>
  
  <pre><code>    Application:
            Hosts:
                - a
                - b
  </code></pre>
  
  <p>sample.json.templete</p>
  
  <pre><code>     [{
  "test1": 
  {
  
                    "objectName": "{{Application.Hosts}}",
  
                   }
  
  
  }]
  </code></pre>
  
  <p>when I run </p>
  
  <pre><code>   python ./render.py ./test.yaml ./sample.json.templete &gt; sample.json
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>   [{
  "test1": 
  {
  
                    "objectName": ['a' , 'b'],
  
                   }
  
  
  }]
  </code></pre>
  
  <p>But since I am generating a json file I need</p>
  
  <pre><code>     ["a", "b"]
  </code></pre>
  
  <p>I.e. I want the list in double quotes. How do I best achieve it? How do I convert list with strings in single quotes to list with strings in double quotes?</p>