mirror of
https://github.com/cpacker/MemGPT.git
synced 2025-06-03 04:30:22 +00:00
16 lines
396 B
Python
16 lines
396 B
Python
import json
|
|
from datetime import datetime
|
|
|
|
|
|
def json_loads(data):
|
|
return json.loads(data, strict=False)
|
|
|
|
|
|
def json_dumps(data, indent=2):
|
|
def safe_serializer(obj):
|
|
if isinstance(obj, datetime):
|
|
return obj.isoformat()
|
|
raise TypeError(f"Type {type(obj)} not serializable")
|
|
|
|
return json.dumps(data, indent=indent, default=safe_serializer, ensure_ascii=False)
|