How do I return a json object of my database table I'm creating a web client that uses data from my database to plot markers on a google map. So my collumns are id, name, address, lat, lon, description. My client gets the data from a route in my restful server.

I am currently using flask in my python server.  This is the current code on my route on my server.

@testRestServer.route("/dbMap", methods=['GET', 'POST'])
def getData():
    cursor.execute("SELECT * FROM markers ")
    return jsonify(cursor.fetchall())


This is the output of the json i get, however i'm unable to manipulate it correclty to work with my google maps code as it has none of the headers as reference.

[
  [
    1, 
    "Test1", 
    "york", 
    53.95734, 
    -1.086833, 
    "test1"
  ], 
  [
    2, 
    "Test2", 
    "york", 
    53.961533, 
    -1.085244, 
    "test2"
  ], 
  [
    3, 
    "Test3", 
    "york", 
    53.963051, 
    -1.078202, 
    "test3"
  ], 
  [
    4, 
    "Test4", 
    "york", 
    53.963104, 
    -1.082185, 
    "test4"
  ]
   ]


I'm not sure why its not outputting like this and not with the column names like this which i believe is what i need to be doing. 

[
{"name": "test1"
 "address": "york"
  "lat" : "53.963104"}
]


I still need to work out if its best to return the column header as a string or key but if i can try either option and see which works best.
Any assistance on how I could return an output like the latter would be greatly appreciated.  

Many thanks

This is the latest code with the error TypeError: 'int' object has no attribute 'getitem'

@testRestServer.route("/dbMap", methods=['GET', 'POST'])
def getData():
    #    cursor.execute("SELECT * FROM locations ")
    #    return jsonify(cursor.fetchall())

    records = cursor.execute("SELECT * FROM locations ")
    payload = []
    content = {}
    for result in range(records):
        content = {'id': result[0], 'name': result[1], 'address': result[2], 'lat': result[3], 'lon': result[4], 'description': result[5]}
        payload.append(content)
        return jsonify(payload)
So with a bit of hunting and adapting, i resolved the issue with a different method.  I'll post it here incase someone else has an issue similar to this in the future.

The completed route in the server to get the json working correctly is

@testRestServer.route("/dbMap", methods=['GET', 'POST'])
def getData():

cursor.execute('''SELECT * FROM locations ''')
row_headers = [x[0] for x in cursor.description]  # this will extract row headers
rv = cursor.fetchall()
json_data = []
for result in rv:
    json_data.append(dict(zip(row_headers, result)))
return json.dumps(json_data)