koajs / koa-body

koa body parser middleware
MIT License
950 stars 130 forks source link

when i use 'requests.post(url=xxx, json=json.dumps({...}))', got 'invalid JSON, only supports object and array' #184

Closed neal-wyz closed 4 years ago

neal-wyz commented 4 years ago

Problem/Feature Request Summary

when i use 'requests.post(url=xxx, json=json.dumps({...}))', got 'invalid JSON, only supports object and array'

Environment Information

Current Behavior

when i use python

report_data = {"taskid": "1", "poid": "2", "tooid": "1", "instance": ["111", "111", "111"], "count": 3}
res = requests.post(url=url,  json=json.dumps(report_data))

i got

server error Error: invalid JSON, only supports object and array at parse (/home/systemuser/kafka-node/node_modules/koa-body/node_modules/co-body/lib/json.js:60:13) at /home/systemuser/kafka-node/node_modules/koa-body/node_modules/co-body/lib/json.js:45:22 at processTicksAndRejections (internal/process/task_queues.js:97:5) { status: 400, body: '"{\"taskid\": \"1\", \"poid\": \"2\", \"tooid\": \"1\", \"instance\": [\"111\", \"111\", \"111\"], \"count\": 3}"' }

Steps to Reproduce

1. 2. 3.

Expected Behavior

Possible Solution

Context (Environment)