get_json

        High-level api: get_json returns json_val of the config node.

        Parameters
        ----------

        instance : `bool`
            True if only one instance of list or leaf-list is required. False if
            all instances of list or leaf-list are needed.

        Returns
        -------

        str
            A string in JSON format.

def get_json(self, instance=True, origin='openconfig'):
        '''get_json

        High-level api: get_json returns json_val of the config node.

        Parameters
        ----------

        instance : `bool`
            True if only one instance of list or leaf-list is required. False if
            all instances of list or leaf-list are needed.

        Returns
        -------

        str
            A string in JSON format.
        '''

        def get_json_instance(node):
            pk = Parker(xml_fromstring=_fromstring, dict_type=OrderedDict)
            default_ns = {}
            for item in node.iter():
                parents = [p for p in node.iter() if item in p]
                if parents and id(parents[0]) in default_ns:
                    ns, tag = self.device.convert_tag(default_ns[id(parents[0])],
                                                      item.tag,
                                                      dst=ns_spec[origin]['val_name'])
                else:
                    ns, tag = self.device.convert_tag('',
                                                      item.tag,
                                                      dst=ns_spec[origin]['val_name'])
                default_ns[id(item)] = ns
                item.tag = tag
                if item.text:
                    text = self.device.convert_tag(self._url_to_prefix[ns],
                                                   item.text,
                                                   src=Tag.JSON_PREFIX,
                                                   dst=ns_spec[origin]['val_val'])[1]
                    item.text = text
            return pk.data(node)

        def convert_node(node):
            # lxml.etree does not allow tag name like oc-if:enable
            # so it is converted to xml.etree.ElementTree
            string = etree.tostring(node, encoding='unicode',
                                    pretty_print=False)
            return ElementTree.fromstring(string)

        if instance:
            return json.dumps(get_json_instance(convert_node(self.node)))
        else:
            nodes = [n for n in
                     self.node.getparent().iterchildren(tag=self.node.tag)]
            if len(nodes) > 1:
                return json.dumps([get_json_instance(convert_node(n))
                                   for n in nodes])
            else:
                return json.dumps(get_json_instance(convert_node(nodes[0])))