初始化提交

This commit is contained in:
chenxin committed 2026-08-21 16:00:13 +08:00
commit 887c1f449e
963 files changed
+166869

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
"""JSON 文本字段转换工具。"""
import json
from typing import Any
def dumps(value: Any) -> str:
return json.dumps(value, ensure_ascii=False, separators=(",", ":"))
def loads_dict(value: str | None) -> dict[str, Any]:
if not value:
return {}
data = json.loads(value)
return data if isinstance(data, dict) else {}
def loads_list(value: str | None) -> list[str]:
if not value:
return []
data = json.loads(value)
return data if isinstance(data, list) else []