def json_encoder(thing): """ Specialized json encoding. :param thing: An object to be encoded. :return: The encoded object. :rtype: str """ if isinstance(thing, datetime): dt = thing.replace(tzinfo=dateutils.utc_tz()) return dateutils.format_iso8601_datetime(dt) return json_util.default(thing)