Return a rendering of the current state in JSON.

def as_json(self, path="", with_indent=False):
        """
        Return a rendering of the current state in JSON.

        """
        if path not in self.top_level_links:
            raise StateError("Unknown path")

        return json.dumps(self.get_state_repr(path),
                          indent=4 if with_indent else None)