ramonhagenaars / jsons

🐍 A Python lib for (de)serializing Python objects to/from JSON
https://jsons.readthedocs.io
MIT License
289 stars 41 forks source link

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

Open duxbuse opened 2 years ago

duxbuse commented 2 years ago

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

ramonhagenaars commented 2 years ago

Hi @duxbuse ,

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

duxbuse commented 2 years ago

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

Bluscream commented 3 months ago

why is this still not support?