def render(self, data, template=None):
        if not isinstance(data, (list, tuple)):
            data = [data]

        if len(data) == 0:
            return

        try:
            kwargs = {}
            if self.app.pargs.format_json:
                kwargs['sort_keys'] = True
                kwargs['indent'] = 4

            json_data = [row.serialize() for row in data]
            json.dump(
                json_data,
                sys.stdout,
                default=json_util.default,
                **kwargs
            )
        except IOError:
            # Handle pipes that could close before output is done.
            # See http://stackoverflow.com/questions/15793886/
            try:
                sys.stdout.close()
            except __HOLE__:
                pass
            try:
                sys.stderr.close()
            except IOError:
                pass
dataset/ETHPy150Open newsdev/nyt-clerk/clerk/ext_json.py/ElexJSONOutputHandler.render