OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

BaseModel.model_dump_json() got an unexpected keyword argument 'serialize_as_any'

  • Thread starter Thread starter Anton
  • Start date Start date
A

Anton

Guest
I use pydantic 2.5.3.

Here my code

Code:
from pydantic import BaseModel

class A(BaseModel):
    a: float = 0.0

When I do

Code:
a = A()
a.model_dump_json(serialize_as_any = True)

I got an error

Code:
        a = A()
>       a.model_dump_json(serialize_as_any = False)
E       TypeError: BaseModel.model_dump_json() got an unexpected keyword argument 'serialize_as_any'

but according documentation it should work

Maybe I miss something?
<p>I use pydantic 2.5.3.</p>
<p>Here my code</p>
<pre><code>from pydantic import BaseModel

class A(BaseModel):
a: float = 0.0
</code></pre>
<p>When I do</p>
<pre><code>a = A()
a.model_dump_json(serialize_as_any = True)
</code></pre>
<p>I got an error</p>
<pre><code> a = A()
> a.model_dump_json(serialize_as_any = False)
E TypeError: BaseModel.model_dump_json() got an unexpected keyword argument 'serialize_as_any'
</code></pre>
<p>but according <a href="https://docs.pydantic.dev/latest/concepts/serialization/#serialize_as_any-runtime-setting" rel="nofollow noreferrer">documentation</a> it should work</p>
<p>Maybe I miss something?</p>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top