Wie baue ich pydantische Modelle auf, die nicht zur Serialisierung nachkommen?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie baue ich pydantische Modelle auf, die nicht zur Serialisierung nachkommen?

by Anonymous » 10 Feb 2025, 18:18

Ich suche nach einer Möglichkeit, ein Modell zu erstellen.
Gewünschtes Verhalten: bar wird nach Foo .
validiert

Code: Select all

y = Bar(bar=Foo('xxx'))
< /code>
gewünschte Ausgabe: < /p>
print(y.json())
# {"bar": "xxx"}

Top