class Raw(str): pass class MyJSONEncoder(JSONEncoder): def _iterencode(self, o, markers=None): if isinstance(o, Raw): yield o else: for chunk in JSONEncoder._iterencode(self, o, markers): yield chunk def default(self, o): return Raw("new StrannayaHuinya(111)")