-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
key alias for jsonclasses #40
Comments
Hi @ViktorSky, I guess we can. |
How is it done? I have been reading the documentation but I have only found the references with ´linkedBy/linkedTo´, I have also read the source code, but it is a bit confusing to handle the modifiers |
Hi @ViktorSky, do you mean nested models? |
No, I meant to specify the key for the field. @jsonclass
class User:
name: str = types.str.alias('userName')
type: int = types.int.alias('userType')
data = {
'userName': 'John',
'userType': 0
}
user = User(**data)
print(user)
"""
User(userName='John')
"""
print(user.name)
"""
John
"""
|
#40 (comment) |
Is there anyone reading? |
Is it possible to get the value from aliases?
this happens because the key value is too long to call the attributes
eg: here api returns something with repetitive or long text
and making the jsonclass of this is tedious and repetitive with the name
If suggestions are accepted, I would ask that a method be added to get the key from the dict, to use the value in an alias as shown below.
The text was updated successfully, but these errors were encountered: