title: Python: Preventing json.load(file) from stripping escape characters
body: <p>I am loading some data into Python from an external json file, which for the most part works fine. However occasionally some of the data contains escaped characters, which I need to retain.</p>
  
  <h3>raw input file:</h3>
  
  <pre><code>{
      "version": 1,
      "query": "occasionally I \"need\" to escape \"double\" quotes"
  } 
  </code></pre>
  
  <h3>loading it into python:</h3>
  
  <pre><code>import json
  
  with open('input_file', 'r') as f:
      file = json.load(f)
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>Apologies I should be clearer. What I am trying to do is something like the following:</p>
  
  <pre><code>'{}'.format(file['query'])
  </code></pre>
  
  <h2>Using json.dumps</h2>
  
  <pre><code>actual_query = '"datadog.agent.up".over("role:dns").by("host").last(1).count_by_status()'
  
  json.dumps(actual_query)
  '"\\"datadog.agent.up\\".over(\\"role:dns\\").by(\\"host\\").last(1).count_by_status()"'
  </code></pre>