Flask REST API中的Python/JSON解析错误

2024-09-28 19:03:05 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是我发送的数据:

   {
    "customer": {
        "CustomerName": "John Doe",
        "PhoneNumber": "123-234-5678",
        "FaxNumber": "123-234-5678",
        "WebsiteURL": "http://www.something.com",
        "Delivery": {
            "AddressLine1": "One Microsoft Way",
            "PostalCode": "98052"
        }
    }
}

我收到的错误是:

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

以下是处理请求的代码:

def put(self):
    args = parser.parse_args()
    customer = json.loads(args['customer'])
    result = self.executeQueryJson("put", customer)
    return result, 201

我错过了什么


Tags: 数据selfjsonhttpputwwwargscustomer