mongoengine to_json反斜杠格式

时间:2018-10-03 10:17:52

标签: python

我有这段代码,该代码使用mongoengine从mongodb返回json格式

def getPaymentDetails(paymentID):
    # invoice = Invoice.objects(id = paymentID).first()

    try:
        invoice = Invoice.objects(id = paymentID).first()

    except ValidationError as e:
        return  json.dumps({"Error": str(e)})

    if invoice is None:
        return  json.dumps({"Not Found": 'NO RECORD'})

    return invoice.to_json()

这是一个例子

\"paymentReferenceId\": \"5BXe}>'r!M\"

键和值的开头和结尾处都有反斜杠

对此有任何解决办法吗?谢谢

0 个答案:

没有答案