Robyn
Robyn copied to clipboard
request.json() does not handle arrays properly
Payload:
{
"sources": ["google_docs", "notion"]
}
Code:
@app.post("/search")
async def search(request):
request_data = request.json()
sources = request_data.get("sources", [])
returns a string ["google_docs","notion"]
using json.loads() makes it work
Yes, I also encountered this issue. Is this expected?
but,i see “# Robyn's request.json() returns a dict, no need for await”, What went wrong?
I've worked this around with:
from orjson import loads
...
data = loads(req.body)
but please fix it.