My code:
cursor = conn.cursor()
cursor.execute("EXEC prcFetch") # Fetching Json data from database via stored procedure
res = cursor.fetchall()
conn.close()
print(res) # type(res) is list
Stored procedure:
GO
CREATE PROCEDURE prcFetch AS
BEGIN
SELECT *
FROM JsonData
FOR JSON PATH
END
Output:
[('[{"Name":"abc","Age":"25","Gender":"M"}]',)]
I tried to deserialize the above output.
print(json.loads(res))
Error:
TypeError: the JSON object must be str, bytes or bytearray, not list