-
Notifications
You must be signed in to change notification settings - Fork 188
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
from_json method to load tree from json. #105
base: master
Are you sure you want to change the base?
Conversation
if children: | ||
yield (k, data, parent_id) | ||
for child in children: | ||
yield from _iter(child, k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration test failed, yield from ...
syntax was introduced in python 3.3. To support 2.6 and 2.7 I'd suggest the following change:
yield from _iter(child, k) | |
for i in _iter(child, k): | |
yield i |
Are there any updates on this, from_json seems to be failing even on simple trees. |
Any update ? |
I think a better implementation is below:
This will ensure you will be able to recreate a tree if the only thing you are interested in is the tags (which may be duplicated). A good example would be a binary tree or boolean expression tree. The only improvement would be how you would specify the class constructor in this classmethod. once you have the from_dict method, you can implement from_json by just json.load(d) and calling from_dict. |
No description provided.