karunpoudel commented on PR #22744:
URL: https://github.com/apache/airflow/pull/22744#issuecomment-1088726849
> The `tojson` filter should already be producing valid JSON. I wonder why
it is not.
@ashb, the regular json string works if you are writing to a file or sending
as html response where the backslash are interpreted as literal character. The
problem is that the json string is part of your code, not the literal string
data. There is two step of parsing going on client side: 1st, it is parse by
javascript to convert it to string and then by JSON.parse().
Another way to fix this without manually replacing is by using python's
`repr()` function. Once we register it filter, then we can use it as
`const data = JSON.parse({{ data | tojson | repr }});`
This might be cleaner way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]