Source code for ultipa.structs.BaseModel

# -*- coding: utf-8 -*-
# @Time    : 2023/8/4 10:29
# @Author  : Ultipa
# @Email   : [email protected]
# @File    : BaseModel.py
import json
from typing import Dict


[docs] class BaseModel: ''' Processing class that defines settings for returned data related operations. '''
[docs] def toJSON(self, pretty=False): try: if pretty: return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4, ensure_ascii=False) else: return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, ensure_ascii=False) except Exception as e: return self
[docs] def toDict(self): return json.loads(self.toJSON())
def __str__(self): return str(self.__dict__)