Representing money, dates, and enums
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
pick formats that never lose information.
Planned topics
- Money: never
doubleorfloat(rounding errors). Use integer minor units (priceCents) or a decimal string, plus a currency code. - Dates and times: ISO 8601 with an offset or UTC, for example
2026-03-01T10:15:30Z. A time without an offset is ambiguous. - Enums: send stable uppercase strings (
"SHIPPED"), not ordinal numbers; document the allowed values. - Use the same formats in requests and responses.
- Unknown enum values from the client should give
400.
Draft outline details
Demonstration
{ "total": { "amount": 1999, "currency": "SAR" },
"createdAt": "2026-03-01T10:15:30Z",
"status": "SHIPPED" }Check your understanding
Why not 0.1 + 0.2 for money?
Show answer
Floating point cannot represent it exactly.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.