def get_json(self, instance=True, origin='<STR_LIT>'):
def get_json_instance(node):<EOL><INDENT>pk = Parker(xml_fromstring=_fromstring, dict_type=OrderedDict)<EOL>default_ns = {}<EOL>for item in node.iter():<EOL><INDENT>parents = [p for p in node.iter() if item in p]<EOL>if parents and id(parents[<NUM_LIT:0>]) in default_ns:<EOL><INDENT>ns, tag = self.device.convert_tag(default_ns[id(parents[<NUM_LIT:0>])],<EOL>item.tag,<EOL>dst=ns_spec[origin]['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>ns, tag = self.device.convert_tag('<STR_LIT>',<EOL>item.tag,<EOL>dst=ns_spec[origin]['<STR_LIT>'])<EOL><DEDENT>default_ns[id(item)] = ns<EOL>item.tag = tag<EOL>if item.text:<EOL><INDENT>text = self.device.convert_tag(self._url_to_prefix[ns],<EOL>item.text,<EOL>src=Tag.JSON_PREFIX,<EOL>dst=ns_spec[origin]['<STR_LIT>'])[<NUM_LIT:1>]<EOL>item.text = text<EOL><DEDENT><DEDENT>return pk.data(node)<EOL><DEDENT>def convert_node(node):<EOL><INDENT>string = etree.tostring(node, encoding='<STR_LIT>',<EOL>pretty_print=False)<EOL>return ElementTree.fromstring(string)<EOL><DEDENT>if instance:<EOL><INDENT>return json.dumps(get_json_instance(convert_node(self.node)))<EOL><DEDENT>else:<EOL><INDENT>nodes = [n for n in<EOL>self.node.getparent().iterchildren(tag=self.node.tag)]<EOL>if len(nodes) > <NUM_LIT:1>:<EOL><INDENT>return json.dumps([get_json_instance(convert_node(n))<EOL>for n in nodes])<EOL><DEDENT>else:<EOL><INDENT>return json.dumps(get_json_instance(convert_node(nodes[<NUM_LIT:0>])))<EOL><DEDENT><DEDENT>
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.