0

I have a response from a data base request saved in a list and sent as a parameter response to following function:

phython3

def sendReponse(status, myStatusCode, message, response):
if myStatusCode == 200:
    cleaned = json.loads(response)
      #       {
      #      "instanceIdJobCreator": "instance-x44",
      #      "component": "mapper",
      #      "jobParameter": "{\"alice\":\"bob\",\"foo\":\"bar\",\"va1\":\"bmw-x-5\"}",
      #      "jobStatus": "created",
      #      "itemType": "job",
      #      "createTime": "2019-07-06T14:57:31.577Z",
      #      "id": "job-1GXSBjK1pI-b9gs88Azwv-BCvkU-mO6"
      #       }
    data = {"status": status, 
            "info": message,
            "data": cleaned
            }
else:
    data = {"status": status, 
            "info": message
            }
headers = {'Content-type': 'application/json'}
message = dict(statusCode=myStatusCode,
            isBase64Encoded=False,
            headers=headers,
            body=data)
return message

The issue I have now is that the nested items in ""jobParamter" have backslash added:

"jobParameter": "{\"alice\":\"bob\",\"foo\":\"bar\",\"va1\":\"bmw-x-5\"}"

Is there a way to remove them? I already stried to response.replace('\"','"'), but for some reason the response string didn't replace the backslashes...

Jake2Finn
  • 516
  • 5
  • 19

0 Answers0