code: def serialize(self, private=False):
          
          if not self.priv_key and not self.pub_key:
              raise SerializationNotPossible()
  
          res = self.common()
  
          public_longs = list(set(self.public_members) & set(self.longs))
          for param in public_longs:
              item = getattr(self, param)
              if item:
                  res[param] = item
  
          if private:
              for param in self.longs:
                  if not private and param in ["d", "p", "q", "dp", "dq", "di",
                                               "qi"]:
                      continue
                  item = getattr(self, param)
                  if item:
                      res[param] = item
          if self.x5c:
              res['x5c'] = [x.decode('utf-8') for x in self.x5c]
  
          return res
docs: Given a cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
          RSAPublicKey instance construct the JWK representation.
  
          :param private: Should I do the private part or not
          :return: A JWK as a dictionary