# Path: anytree/importer/dictimporter.py
# class DictImporter(object):
# 
#     def __init__(self, nodecls=AnyNode):
#         u"""
#         Import Tree from dictionary.
# 
#         Every dictionary is converted to an instance of `nodecls`.
#         The dictionaries listed in the children attribute are converted
#         likewise and added as children.
# 
#         Keyword Args:
#             nodecls: class used for nodes.
# 
#         >>> from anytree.importer import DictImporter
#         >>> from anytree import RenderTree
#         >>> importer = DictImporter()
#         >>> data = {
#         ...     'a': 'root',
#         ...     'children': [{'a': 'sub0',
#         ...                   'children': [{'a': 'sub0A', 'b': 'foo'}, {'a': 'sub0B'}]},
#         ...                  {'a': 'sub1'}]}
#         >>> root = importer.import_(data)
#         >>> print(RenderTree(root))
#         AnyNode(a='root')
#         ├── AnyNode(a='sub0')
#         │   ├── AnyNode(a='sub0A', b='foo')
#         │   └── AnyNode(a='sub0B')
#         └── AnyNode(a='sub1')
#         """
#         self.nodecls = nodecls
# 
#     def import_(self, data):
#         """Import tree from `data`."""
#         return self.__import(data)
# 
#     def __import(self, data, parent=None):
#         assert isinstance(data, dict)
#         assert "parent" not in data
#         attrs = dict(data)
#         children = attrs.pop("children", [])
#         node = self.nodecls(parent=parent, **attrs)
#         for child in children:
#             self.__import(child, parent=node)
#         return node


import json
from .dictimporter import DictImporter
# -*- coding: utf-8 -*-



class JsonImporter(object):

    def __init__(self, dictimporter=None, **kwargs):
        u"""
        Import Tree from JSON.

        The JSON is read and converted to a dictionary via `dictimporter`.

        Keyword Arguments:
            dictimporter: Dictionary Importer used (see :any:`DictImporter`).
            kwargs: All other arguments are passed to
                    :any:`json.load`/:any:`json.loads`.
                    See documentation for reference.

        >>> from anytree.importer import JsonImporter
        >>> from anytree import RenderTree
        >>> importer = JsonImporter()
        >>> data = '''
        ... {
        ...   "a": "root",
        ...   "children": [
        ...     {
        ...       "a": "sub0",

# Path: anytree/importer/dictimporter.py
# class DictImporter(object):
# 
#     def __init__(self, nodecls=AnyNode):
#         u"""
#         Import Tree from dictionary.
# 
#         Every dictionary is converted to an instance of `nodecls`.
#         The dictionaries listed in the children attribute are converted
#         likewise and added as children.
# 
#         Keyword Args:
#             nodecls: class used for nodes.
# 
#         >>> from anytree.importer import DictImporter
#         >>> from anytree import RenderTree
#         >>> importer = DictImporter()
#         >>> data = {
#         ...     'a': 'root',
#         ...     'children': [{'a': 'sub0',
#         ...                   'children': [{'a': 'sub0A', 'b': 'foo'}, {'a': 'sub0B'}]},
#         ...                  {'a': 'sub1'}]}
#         >>> root = importer.import_(data)
#         >>> print(RenderTree(root))
#         AnyNode(a='root')
#         ├── AnyNode(a='sub0')
#         │   ├── AnyNode(a='sub0A', b='foo')
#         │   └── AnyNode(a='sub0B')
#         └── AnyNode(a='sub1')
#         """
#         self.nodecls = nodecls
# 
#     def import_(self, data):
#         """Import tree from `data`."""
#         return self.__import(data)
# 
#     def __import(self, data, parent=None):
#         assert isinstance(data, dict)
#         assert "parent" not in data
#         attrs = dict(data)
#         children = attrs.pop("children", [])
#         node = self.nodecls(parent=parent, **attrs)
#         for child in children:
#             self.__import(child, parent=node)
#         return node


# Path: anytree/importer/jsonimporter.py
import json
from .dictimporter import DictImporter

# -*- coding: utf-8 -*-



class JsonImporter(object):

    def __init__(self, dictimporter=None, **kwargs):
        u"""
        Import Tree from JSON.

        The JSON is read and converted to a dictionary via `dictimporter`.

        Keyword Arguments:
            dictimporter: Dictionary Importer used (see :any:`DictImporter`).
            kwargs: All other arguments are passed to
                    :any:`json.load`/:any:`json.loads`.
                    See documentation for reference.

        >>> from anytree.importer import JsonImporter
        >>> from anytree import RenderTree
        >>> importer = JsonImporter()
        >>> data = '''
        ... {
        ...   "a": "root",
        ...   "children": [
        ...     {
        ...       "a": "sub0",

        ...       "children": [