Self-Referencing Field Aliases To Segregate Out Sub-Objects #8048
Unanswered
parkerhancock
asked this question in
Question
Replies: 1 comment
-
Did you ever find a workaround for this ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using (and loving!) pydantic in some data parsing projects. One issue I've run into is that I'm getting very large and "flat" JSON objects, like this:
And I want to parse it into Pydantic objects that, when dumped, look like this:
Is there a way to do this using purely pydantic? Something like (and I know this doesn't work):
Is there something I can put for "Self" that works? Or some variant of
AliasPath
orAliasChoices
(or something like that) that would work as anAliasSelf
?For the sake of conversation, assume the real data here has >200 fields that should actually be segregated out into about a dozen sub-objects, and that writing a function to do data reshaping on the input without Pydantic would be complex and hard to maintain.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions