I have a Python API that receives data from mysql select query. The data looks like this:
| val | type | status |
|-----|------|--------|
| 90 | 1 | a |
That data was received well in python. Now I want to present that data as JSON to my REST client - how?
Here is my python code:
def somefunction(self, by, identifier):
# validate args
procedure = 'mysproc' + str(by)
try:
with self.connection.cursor() as cursor:
cursor.callproc(procedure,[str(identifier)])
self.connection.commit()
result = cursor.fetchone()
print("+++ Result: " + str(result) + " +++")
except:
result = "Request Failed"
raise
finally:
self.DestroyConnection()
return json.dumps(result)
with that, my client is receiving:
"[90, 1, "a"]"
Question:
is there a way for me to receive it as a proper JSON? like:
{'val': 90, 'type': 1 , : 'status': "a"}