I have a class
class Person(object):
def __init__(self,age,name):
self.person_age = age
self.person_name = name
And i want to serialize object to json. I can do so:
person = Person(20,'Piter')
person.__dict__
But such an approach will return it:
{'person_age':20,person_name:'Piter'}
I want serialize my object to json with my own fields. Instead of 'person_age' - 'age'. Instead of 'person_name' - 'name':
{'age':20,name:'Piter'}
How can this be done if the class has many fields?