How to convert a list of dictionaries to JSON in Python / Django?
<p>I searched on Google and found an answer but it's not working for me. I have to send a list as <code>JsonResponse</code> in Django, similar to this:</p>

<pre><code>list_to_json =[{"title": "hello there",
                "link": "www.domain.com",
                "date":   ...},
               {},{},{},...]
</code></pre>

<p>I am converting this to JSON by applying StackOverflow <a href="https://stackoverflow.com/questions/11312733/python-convert-a-list-of-python-dictionaries-to-an-array-of-json-objects">question1</a> and <a href="https://stackoverflow.com/questions/21525328/python-converting-a-list-of-dictionaries-to-json">question2</a> but it's not working for me. I get the following error:</p>

<p><strong>In order to allow non-dict objects to be serialized set the safe parameter to False</strong></p>

<p>Here's my code:</p>

<pre><code>    def json_response(request):
        list_to_json=[{"title": ..., "link": ..., "date": ...},{...}]
        return JsonResponse(json.dumps(list_to_json) )
</code></pre>