From 73410f136e93c0a8742697e20cdae2af9e74c005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Mon, 1 May 2023 19:17:44 +0800 Subject: [PATCH] :sparkles: Add `APIModel` --- simnet/models/base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 simnet/models/base.py diff --git a/simnet/models/base.py b/simnet/models/base.py new file mode 100644 index 0000000..9f2c99f --- /dev/null +++ b/simnet/models/base.py @@ -0,0 +1,16 @@ +from pydantic import BaseModel + +try: + import ujson as jsonlib +except ImportError: + import json as jsonlib + + +class APIModel(BaseModel): + """A Pydantic BaseModel class used for modeling JSON data returned by an API.""" + + class Config: + """A nested class defining configuration options for the APIModel.""" + + json_dumps = jsonlib.dumps + json_loads = jsonlib.loads