I am trying to build a very simple code SQL code formatter, which extracts the query from a JSON object and the goal is to copy the final output to the clipboard. I have not got to the clipboard part yet, because I could not get Python to interpret escape characters.
print function prints the whole thing with escape characters and all, and I cannot figure out why.
import json
main_query = {"text": "SELECT\n * from test where id = 1\n LIMIT 10"}
query = str(json.dumps(main_query['text']).strip('"'))
print(query) # Not working
print('{}'.format(query)) # Not working either
"""
Output:
SELECT\n * from test where id = 1\n LIMIT 10
SELECT\n * from test where id = 1\n LIMIT 10
"""