Many of the programmers might have faced the problem of serializing objects of depth `N` or serializing nested objects. Personally i have also faced such a situation and here is the solution which i found. There may be better implementations of serializing nested objects, but i think this might be helpful for some novices like me.
subject = 'ECE'
college = 'Jyothi Engineering College'
_serializable_fields = ['subject', 'college']
designation = 'Software Engineer'
company = 'Scintilla Technologies'
_serializable_fields = ['designation', 'company']
name = 'Akhil Lawrence'
age = 23
job = Programmer()
education = Engineering()
_serializable_fields = ['name', 'age', 'job', 'education']
def Serialize(obj, excludes=):
response = dict()
for attr_name in obj._serializable_fields:
if attr_name in excludes:
attr = getattr(obj, attr_name)
if attr and not isinstance(attr, Reference):
elif attr and isinstance(attr, Reference):
def Serializer(objs, excludes=):
response = 
for obj in objs:
if __name__ == '__main__':
objs = [Individual(), Individual()]
excludes = 
print json.dumps(Serializer(objs, excludes), indent=4)