Skip to content

Commit

Permalink
Remove code for classes natively supported by orjson.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed Feb 28, 2025
1 parent fd77851 commit f8f5cb0
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions eliot/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import sys
from pathlib import Path
from datetime import date, time
from uuid import UUID
from enum import Enum


class EliotJSONEncoder(json.JSONEncoder):
Expand Down Expand Up @@ -50,10 +48,6 @@ def json_default(o: object) -> object:
if pydantic is not None and isinstance(o, pydantic.BaseModel):
return o.model_dump()

# Add dataclass support
if hasattr(o, "__dataclass_fields__"):
return {field: getattr(o, field) for field in o.__dataclass_fields__}

if isinstance(o, Path):
return str(o)

Expand All @@ -63,24 +57,12 @@ def json_default(o: object) -> object:
if isinstance(o, time):
return o.isoformat()

if isinstance(o, UUID):
return str(o)

if isinstance(o, set):
return list(o)

if isinstance(o, complex):
return {"real": o.real, "imag": o.imag}

# Add Enum support
if isinstance(o, Enum):
return {
"__enum__": True,
"name": o.name,
"value": o.value,
"class": o.__class__.__name__,
}

# Add Pandas support
pandas = sys.modules.get("pandas", None)
if pandas is not None:
Expand Down

0 comments on commit f8f5cb0

Please sign in to comment.