Serialize to JSON, which can be returned e.g. via RPC

def to_json(self):
        """
        Serialize to JSON, which can be returned e.g. via RPC
        """
        ret = {
            'address': self.address,
            'domain': self.domain,
            'block_number': self.block_height,
            'sequence': self.n,
            'txid': self.txid,
            'value_hash': get_zonefile_data_hash(self.zonefile_str),
            'zonefile': base64.b64encode(self.zonefile_str),
            'name': self.get_fqn(),
        }
        
        if self.pending is not None:
            ret['pending'] = self.pending

        if self.resolver is not None:
            ret['resolver'] = self.resolver

        return ret