On 5/29/24 13:27, Larry Martell via Python-list wrote:
On Tue, May 28, 2024 at 11:46 AM Left Right via Python-list
wrote:
Most Python objects aren't serializable into JSON. Pydantic isn't
special in this sense.
What can you do about this? -- Well, if this is a one-of situation,
then, maybe ju
On Wed, May 29, 2024 at 12:27 PM Larry Martell wrote:
>
> On Tue, May 28, 2024 at 11:46 AM Left Right via Python-list
> wrote:
> >
> > Most Python objects aren't serializable into JSON. Pydantic isn't
> > special in this sense.
> >
> > What can you do about this? -- Well, if this is a one-of situ
On Tue, May 28, 2024 at 11:46 AM Left Right via Python-list
wrote:
>
> Most Python objects aren't serializable into JSON. Pydantic isn't
> special in this sense.
>
> What can you do about this? -- Well, if this is a one-of situation,
> then, maybe just do it by hand?
>
> If this is a recurring pro
Most Python objects aren't serializable into JSON. Pydantic isn't
special in this sense.
What can you do about this? -- Well, if this is a one-of situation,
then, maybe just do it by hand?
If this is a recurring problem: json.dumps() takes a cls argument that
will be used to do the serialization.
Just getting started with pydantic. I have this example code:
class FinishReason(Enum):
stop = 'stop'
class Choice(BaseModel):
finish_reason: FinishReason = Field(...)
But I cannot serialize this:
json.dumps(Choice(finish_reason=FinishReason.stop).dict())
*** TypeError: Object of type