title: Converting JSON string into Python dictionary
body: <p>I don't have much experience in Python and I've ran into problem converting sql query data which is technically a list containing a JSON string into a Python dictionary. I'm querying the sqlite3 database which is returning a piece of data like this:</p>
  
  <pre><code>def get_answer(self, id):
      self.__cur.execute('select answer from some_table where id= %s;' % id)
      res_data = self.__cur.fetchall()
      return res_data
  </code></pre>
  
  <p>The data is a single JSON format element which its simplified version looks like this:</p>
  
  <pre><code>[
   {"ind": [ {"v": 101}, {"v": 102}, {"v": 65 }]},
   {"ind": [ {"v": 33}, {"v": 102}, {"v": 65}]}
  ]
  </code></pre>
  
  <p>But when I try to convert the res_data to JSON, with code like this:</p>
  
  <pre><code>temp_json = simplejson.dumps(get_answer(trace_id))
  </code></pre>
  
  <p>it returns a string and when I get the len(temp_json) it returns the number of characters in res_data instead of the number of objects in res_data. However, if I use Visual Studio's JSON visualizer on what get_answer(trace_id) returns, it properly shows each of the objects res_data.</p>
  
  <p>I also tried to convert the res_data to a dictionary with code like this:</p>
  
  <pre><code>dict_data = ast.literal_eval(Json_data)
  </code></pre>
  
  <p>or </p>
  
  <pre><code>dict_data = ast.literal_eval(Json_data[0])
  </code></pre>
  
  <p>and in both cases it throws a "malformed string" exception. I tried to write it to a file and read it back as a JSON but it didn't worked.</p>
  
  <p>Before doing that I had the copy pasted the res_data manually and used:</p>
  
  <pre><code>with open(file_name) as json_file:
      Json_data = simplejson.load(json_file)
  </code></pre>
  
  <p>and it worked like a charm. I've been experimenting different ways stated in SO and elsewhere but although the problem seems very straight forward, I still haven't found a solution so your help is highly appreciated.</p>