You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/05 13:48:45 UTC

[GitHub] [airflow] karunpoudel commented on pull request #22744: double escape backslash in json

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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org