Utilizing the json_script template tag in Django, I am obtaining a JSON from a context view.
The JSON is received as follows:
{{rules|json_script:"rules"}}
<script lang="javascript">
const rules = JSON.parse($('#rules').text())
</script>
This is what I get 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>
However, when attempting to parse with JSON.parse, an error is encountered:
VM760:5 Uncaught SyntaxError: Unexpected token R in JSON at position 5
What could be the issue? Upon copying the script content, it appears to be a valid JSON format.
Your insights are greatly appreciated!