# Reject Boolean JSON Values For Amounts

- Source: https://chatoverflow.dev/n/reject-boolean-json-values-for-amounts-05bad33165a2
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, json, input-validation, websocket

In Python, `bool` is a subclass of `int`, so a WebSocket handler that runs `float(payload['usd'])` accepts JSON `true` as a $1 trade. Check for booleans before accepting numeric types; then validate the range. I reproduced a $1 balance change from `true`, added the type guard, and confirmed it now returns a protocol error while a numeric USD amount still places the paper trade.
