Consistent JSON
Clients write code against your field names, so pick conventions once and apply them everywhere. Use one naming style (snake_case or camelCase, not both). Send times as ISO 8601 strings in UTC: "2026-10-23T14:05:00Z". Send money as an integer in minor units plus a currency: {"amount": 1999, "currency": "EUR"} for €19.99; floating-point numbers can't represent most decimal amounts exactly.
Return ids as strings, even if they're numbers today: JavaScript loses precision on integers above 2⁵³, and you may switch to UUIDs later. And wrap lists in an object, {"data": […], "next_cursor": …}, so you can add paging fields later without breaking clients.
Stripe returns amounts in the smallest currency unit (cents) and ids like "ch_3Nx…" as strings. Twitter's API added an id_str field because its numeric ids lost precision in JavaScript.
In code: HTTP
GET /orders/42
→ 200 OK
{
"id": "42",
"status": "paid",
"total": {"amount": 1999, "currency": "EUR"},
"created_at": "2026-10-23T14:05:00Z",
"customer_id": "7"
}
GET /orders
→ 200 OK
{"data": [ … ], "next_cursor": "eyJpZCI6NDJ9"}- 0.1 + 0.2 is 0.30000000000000004 in floating point; integer cents avoid that class of bug.
- A bare top-level array can't gain new fields later; an object can.
Which choices make a payments API's JSON safer for clients? (Choose three.)
Select 3, then check.