Source code for regparser.notice.encoder
from json import JSONEncoder
from regparser.notice.amdparser import Amendment
[docs]class AmendmentEncoder(JSONEncoder):
"""Custom JSON encoder to handle Amendment objects"""
[docs] def default(self, obj):
if isinstance(obj, Amendment):
if obj.destination:
return (obj.action, obj.label, obj.destination)
else:
return (obj.action, obj.label)
return super(AmendmentEncoder, self).default(obj)