Add support of nested paths
grundic opened this issue · 3 comments
Hello!
Great library, lightweight and not overwhelmed -- thanks a lot!
Can you add possibility to specify field disposition in case it's not at root level? Here is small example:
from jsonmodels import models, fields
class User(models.Base):
name = fields.StringField()
salary = fields.IntField()
data = {
'name': 'John Smith',
'data': {
'salary': '100500'
},
}
if __name__ == '__main__':
user = User(**data)
print(user.name)
print(user.salary)
I would like to be able to specify in User
model that the salary
is nested under data
path. And it should be possible to specify nested path. List of strings or usual uri should work fine:
class User(models.Base):
name = fields.StringField()
salary = fields.IntField(nested=['some', 'path'])
# or
salary = fields.IntField(nested='/some/path')
Wrong git repo :=O
Собирал ссылки на declarative frameworks и слегка промазал :)
ok, а то смотрю что примеры не очень похожи =)
но фича весьма интересная, "get dict key by path" этакий
Да, фича хорошая. Возможно для твоей библиотеки тоже пригодится :)
https://www.haykranen.nl/2016/02/13/handling-complex-nested-dicts-in-python/ -- тут пример неплохой как раз по этой теме.