Skip to content

Commit

Permalink
✨ add custom serializer to convert Decimal to float in trips table op…
Browse files Browse the repository at this point in the history
…erations
  • Loading branch information
LokoMoloko98 committed Jan 25, 2025
1 parent 995ccf7 commit f819990
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions swift-lift-trips-table-ops/swift-lift-trips-table-ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
trips_table_name = "Swift-lift-club-portal-trips"
trips_table = dynamodb.Table(trips_table_name)

def custom_serializer(obj):
if isinstance(obj, Decimal):
return float(obj) # Convert Decimal to float
raise TypeError(f"Type {type(obj)} not serializable")

def lambda_handler(event, context):
body = {}
statusCode = 200
Expand Down

0 comments on commit f819990

Please sign in to comment.