I'm using the json_script template tag from django to take a json from a context view.
I receive the json like this
{{rules|json_script:"rules"}}
<script lang="javascript">
const rules = JSON.parse($('#rules').text())
</script>
this is what i receive from {{rules|json_script:"rules"}}
<script id="rules" type="application/json">{"id": 10, "string": "demo", "profile": "Alumno Demo", "license": "Licencia no facturable por usuario demo", "field": "codigo_usuario", "include": true, "order": 1, "uppercase_sensitive": false, "dateadded": "2020-05-11T08:06:35Z", "billable": false}</script>
But when i try to JSON.parse I receive this error:
VM760:5 Uncaught SyntaxError: Unexpected token R in JSON at position 5
What am I doing wrong? If I copy the content of the script it seems like a correct json.
Thanks in advance!
console.log($('#rules').text())and post the output?