I have scraped json data from other web and want to out put to web, but in the backend of flask, it only return a list, just like: [{'aa':'bb', 'cc':'dd'}]. How do I turn it to be json format so js script on html able to get these json data from backend?
app.py:
url1 = requests.get('https://xxxxxxx/getJSON.aspx?jsontype=xxxx.aspx')
json_data = json.loads(url1.content.decode())
json_data = json.dumps(json_data)
json_data = json.loads(json_data)
return render_template('index.html', json_data=json_data)
html script:
<script>
const json_org = JSON.parse({{ json_data }});
const json_data = json_org
;
const output = document.getElementById('output');
output.innerHTML = json_data;
</script>
Error:
Uncaught SyntaxError: Unexpected token '&'
const json_org = JSON.parse([{8name8: 8Current8},...}])