<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def base64(self, extras=()):
 """ Encode json into base64. """

        s = self._marshal_json(extras=extras)
        s_bytes = s if isinstance(s, bytes) else s.encode('utf-8')
        b64enc = base64.b64encode(s_bytes)
        return b64enc.decode('utf-8') if isinstance(b64enc, bytes) else b64enc