Skip to main content

EventSerializer

Custom JSON encoder to assist in the serialization of a wide range of objects.

is_js_safe_integer

Ensure the value is within JavaScript’s safe range for integers. Python’s 64-bit integers can exceed this range, necessitating this check. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

convert_time_delta_to_ns

Convert a timedelta object to nanoseconds.

convert_to_string_dict

Convert a dict with arbitrary values to a dict[str, str] by converting all values to their string representations.

serialize_datetime

Serialize a datetime including timezone info. Uses the timezone info provided if present, otherwise uses the current runtime’s timezone info. UTC datetimes end in “Z” while all other timezones are represented as offset from UTC, e.g. +05:00.

serialize_to_str

Safely serialize data to a JSON string.