Sanic: Error: Overlong 2 byte UTF-8 sequence detected when encoding string

Created on 22 Oct 2016  ·  3Comments  ·  Source: sanic-org/sanic

while return json(doc), doc is fetched from mongodb.

Most helpful comment

Finally I found out that this was caused by the problem of json(mongodb.ObjectID), mongodb.ObjectID cannot be serialized by the json method.

All 3 comments

Hmm, it's possible the encoding of the contents of doc are not utf-8. Do you have some example code I could see?

Finally I found out that this was caused by the problem of json(mongodb.ObjectID), mongodb.ObjectID cannot be serialized by the json method.

@rainyear in pandas the same problem and the same solution. just remove _id and everything fine.

Was this page helpful?
0 / 5 - 0 ratings