jsons icon indicating copy to clipboard operation
jsons copied to clipboard

SerializationError: object of type 'abc' has no len()

Open duxbuse opened this issue 2 years ago • 3 comments

For some reason I cant seem to get a json dump for a pydantic baseModel class object

eg:

import jsons
from pydantic import BaseModel 

class abc(BaseModel):
    value: int

d = abc(value=1)

jsons.dump(d)

OUTPUT SerializationError: object of type 'abc' has no len()

EXPECTED The object should serialise fine.

This is using jsons-1.6.3 and pydantic-1.9.1

duxbuse avatar Aug 03 '22 02:08 duxbuse

Hi @duxbuse ,

Interesting. I have actually been thinking about supporting dumping/loading pydantic models. Right now, it is not supported though.

ramonhagenaars avatar Sep 06 '22 18:09 ramonhagenaars

I would appreciate it, my whole purpose of using jsons is to dump out data classes

duxbuse avatar Sep 07 '22 01:09 duxbuse