Spaces:
Paused
Paused
Download potato/server_utils/json.py from Blablablab/ner-span: direct link, hf CLI and curl.
- Browser
- Download file 452 Bytes
-
https://huggingface.co/spaces/Blablablab/ner-span/resolve/main/potato/server_utils/json.py
- Command line
-
hf download hf://spaces/Blablablab/ner-span/potato/server_utils/json.py
-
curl -L -o json.py https://huggingface.co/spaces/Blablablab/ner-span/resolve/main/potato/server_utils/json.py
452 Bytes
| """ | |
| filename: json.py | |
| date: 10/16/2024 | |
| author: Tristan Hilbert (aka TFlexSoom) | |
| desc: Json encoding utilities for the potato tool | |
| """ | |
| import dataclasses | |
| import json | |
| from typing import Any | |
| class EnhancedJSONEncoder(json.JSONEncoder): | |
| def default(self, o): | |
| if dataclasses.is_dataclass(o): | |
| return dataclasses.asdict(o) | |
| return super().default(o) | |
| def easy_json(obj: Any): | |
| return json.dumps(obj, cls=EnhancedJSONEncoder) |