title: Python json.dump results in 'str' has no attribute 'dump'
body: <p>I am trying to read a JSON file which contains just an object with one property which is the index. That is successful but when i try to rewrite to the same JSON file i get an error.
  The code is bellow :</p>
  
  <pre><code>import sys
  import json
  import os
  import os.path
  import json
  try:
      json_path = path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'indexes', 'table_index.json')
      with open(json_path) as json_file:  
          data = json.load(json_file)
      index1 = 4
      data["index"] = index1
  
      print(type(data)) #Prints 'dict'
      with open((json_path), 'wb') as f:  
          json.dump(data, f)
  except Exception as e: 
       print(e)
  </code></pre>
  
  <p>The error i get is </p>
  
  <pre><code>'str' object has no attribute 'dump'
  </code></pre>
  
  <p>What i am basically trying to achieve is read the JSON, change the index property to a different value and at the end rewrite to the same JSON file.
  Printing data["index"] before writing gives the correct value of 4.</p>