Skip to content

Conversation

@jnovinger
Copy link
Member

Fixes: #20221

This fix actually fixes this for all valid JSON values that evaluate to False in Python when loaded and cast to bool:
bool(json.loads(<val>)).

  • {}
  • []
  • 0
  • False

This does not change the behavior of () or "" which are both explicitly cited as "empty" values on JSONField.

This fix actually fixes this for all valid JSON values that evaluate to
`False` in Python when loaded and cast to bool:
`bool(json.loads(<val>))`.

- `{}`
- `[]`
- `0`
- `False`

This does not change the behavior of `()` or `""` which are both
explicitly cited as "empty" values on `JSONField`.
@jnovinger jnovinger requested review from a team and jeremystretch and removed request for a team September 5, 2025 18:06
@jeremystretch jeremystretch merged commit fcb380b into main Sep 5, 2025
10 checks passed
@jeremystretch jeremystretch deleted the 20221-json-custom-field-cant-handle-empty-object-as-default branch September 5, 2025 19:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON custom field with default value {} is set as null

3 participants