@classmethod
    def tree2json(cls, tree, pretty_print=False, native=False):
        """
            Converts an element tree into JSON

            @param tree: the element tree
            @param pretty_print: provide pretty formatted output
        """

        if isinstance(tree, etree._ElementTree):
            root = tree.getroot()
        else:
            root = tree

        if native or root.tag == cls.TAG.root:
            native = True
        else:
            native = False

        root_dict = cls.__element2json(root, native=native)
        if root_dict in "s3":
            # Don't double JSON-encode
            if root_dict["s3"] == {}:
                del root_dict["s3"]
            else:
                root_dict["s3"] = json.loads(root_dict["s3"])

        if pretty_print:
            js = json.dumps(root_dict, indent=4)
            return "\n".join([l.rstrip() for l in js.splitlines()])
        else:
            return json.dumps(root_dict, separators=SEPARATORS)

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3xml.py/S3XML.tree2json/swapped operands of `in`