I am not sure I fully understand your question, but json.dumps(rows) will create string and your function will return a dict. I think what you actually need is to make the return like this
i.e. I think your function should return str that is valid json, not dict
return json.dumps({ 'statusCode':200, 'headers': {'Access-Control-Allow-Origin': '*'}, 'body': rows })full example
import json def handler(): # assume here it retrieve rows from db rows = [[""], ["Adelaide"], ["Alexandria"], ["Alice Springs"]] return json.dumps({ 'statusCode':200, 'headers': {'Access-Control-Allow-Origin': '*'}, 'body': rows }) print(handler())
Output:{"statusCode": 200, "headers": {"Access-Control-Allow-Origin": "*"}, "body": [[""], ["Adelaide"], ["Alexandria"], ["Alice Springs"]]}
>>>
as you can see it's a valid jsoni.e. I think your function should return str that is valid json, not dict
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs