Skip to content

Commit

Permalink
Merge pull request #91 from rushilsrivastava/main
Browse files Browse the repository at this point in the history
🐛 Add UUID serialization
  • Loading branch information
s-scheele-simonsen authored Jan 9, 2024
2 parents 24770fc + 8b0321e commit 6ce0e3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ poetry.lock
# VSCode
.vscode/

# JetBrains
.idea/

# Direnv
/.envrc
/.direnv
6 changes: 4 additions & 2 deletions axiom/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dacite
import iso8601
from enum import Enum
from uuid import UUID
from typing import Type, TypeVar
from datetime import datetime, timedelta

Expand Down Expand Up @@ -66,9 +67,10 @@ def convert_string_to_timedelta(cls, val: str) -> timedelta:
@classmethod
def handle_json_serialization(cls, obj):
if isinstance(obj, datetime):
d = obj.isoformat("T") + "Z"
return d
return obj.isoformat("T") + "Z"
elif isinstance(obj, timedelta):
return str(obj.seconds) + "s"
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, UUID):
return str(obj)

0 comments on commit 6ce0e3d

Please sign in to comment.