from barely_json import parse from pyparsing import ParseException class JsonString(str): def __new__(cls, plaintext: str): return str.__new__(cls, plaintext) def __init__(self, plaintext: str): pass # def __init__(self, input: str): # super().__init__(input) def parsed(self): try: return parse(self) except ParseException as e: raise ValueError(f"Invalid json-string. Error message: {e}")