def to_json(self, indent=None): return json.dumps(self, default=lambda o: ((float(o) if o % 1 > 0 else int(o)) if isinstance(o, decimal.Decimal) else o.__dict__), sort_keys=True, indent=indent)