def _replace_decimals()

in parquet_flask/aws/aws_ddb.py [0:0]


    def _replace_decimals(self, obj):
        """
        Ref:
            https://stackoverflow.com/a/46738251  in the comments
            https://github.com/boto/boto3/issues/369#issuecomment-157205696

        :param obj:
        :return:
        """
        if isinstance(obj, list):
            for i in range(len(obj)):
                obj[i] = self._replace_decimals(obj[i])
            return obj
        elif isinstance(obj, dict):
            for k in obj.keys():
                obj[k] = self._replace_decimals(obj[k])
            return obj
        elif isinstance(obj, decimal.Decimal):
            if obj % 1 == 0:
                return int(obj)
            else:
                return float(obj)
        else:
            return obj