import json
from datetime import datetime
import time


def iso_to_unix_secs(s):
    """ convert an json str like {'time': '2022-02-05T15:20:09.429963Z'} to microsecs since unix epoch
        as a json str {'usecs': 1644927167429963}
    """
    dt_str = json.loads(s)["time"]
    dt = datetime.strptime(dt_str, "%Y-%m-%dT%H:%M:%S.%fZ")
    usecs = int(time.mktime(dt.timetuple()) * 1000000 + dt.microsecond)
    return json.dumps({"usecs": usecs})