from_json method to load tree from json. - #105
Conversation
| if children: | ||
| yield (k, data, parent_id) | ||
| for child in children: | ||
| yield from _iter(child, k) |
There was a problem hiding this comment.
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. |
|
Closed in favor of #244 . Thanks for you contributions! |
No description provided.