def encode(self, obj):
        """Returns ``obj`` serialized as JSON formatted bytes.

        Raises
        ------
        ~ipfsapi.exceptions.EncodingError

        Parameters
        ----------
        obj : str | list | dict | int
            JSON serializable Python object

        Returns
        -------
            bytes
        """
        try:
            result = json.dumps(obj, sort_keys=True, indent=None,
                                separators=(',', ':'), ensure_ascii=False)
            if isinstance(result, six.text_type):
                return result.encode("utf-8")
            else:
                return result
        except (UnicodeEncodeError, TypeError) as error:
            raise exceptions.EncodingError('json', error)
def encode ( self , obj ) : try : result = json . dumps ( obj , sort_keys = True , indent = None , separators = ( ',' , ':' ) , ensure_ascii = False ) if isinstance ( result , six . text_type ) : return result . encode ( "utf-8" ) else : return result except ( UnicodeEncodeError , TypeError ) as error : raise exceptions . EncodingError ( 'json' , error )
Returns ``obj`` serialized as JSON formatted bytes.

        Raises
        ------
        ~ipfsapi.exceptions.EncodingError

        Parameters
        ----------
        obj : str | list | dict | int
            JSON serializable Python object

        Returns
        -------
            bytes