<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json(self):
 """Return a header as a dictionary."""

        a_per = self.analysis_period.to_json() if self.analysis_period else None
        return {'data_type': self.data_type.to_json(),
                'unit': self.unit,
                'analysis_period': a_per,
                'metadata': self.metadata}