概要
import json class Character: def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) character = Character() character.id = 25 character.name = "ピカチュウ" print(character.toJSON())
import json class Character: def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) character = Character() character.id = 25 character.name = "ピカチュウ" print(character.toJSON())