Repository navigation
Description
Problem to Solve
The current Serverpod database interface does not allow models to declare JSON or JSONB as a field type, nor does it support expressive filtering or querying of arbitrary json/jsonb fields stored in the database, especially when the data structure is unknown or flexible. This limits modeling capabilities as well as advanced querying when working with dynamic or deeply nested JSON fields.
Proposal
Add support for JSON (and/or JSONB) as a first-class field type in Serverpod models and the ORM.- Introduce a query interface for json/jsonb columns that enables expressive, type-safe querying.
- Allow filtering and querying based on any json structure and property, using Dart primitives (String, num, bool, List, Map).
- Support queries such as: 'Find all models where the json field contains a property "name" set to "Alex".'
- Provide a Dart API that allows building predicates for arbitrary nested json structures using familiar Dart syntax.
- Support serialization and translation of these queries to efficient SQL, leveraging PostgreSQL's jsonb query operators.
- Integrate with Serverpod's ORM so that developers can express filters directly in Dart code, regardless of the underlying data shape.
This feature should complement and extend the current capabilities of ColumnSerializable referenced in issue #1591.
API design
TBD, but we would like to provide a typed interface for things that are supported to query on so that the user can not build invalid queries.
Use Case
Useful for storing and retrieving unstructured data.
Alternatives
Alternative approaches considered:
- Relying on direct SQL queries for json/jsonb fields (less type-safe, bypasses ORM)
- Implementing custom Dart extensions for specific json structures (limited flexibility)
- Restricting support to only known json schemas (not dynamic enough for most use cases)
These alternatives were deemed too limiting or not developer-friendly in dynamic data scenarios.
Additional context
See original issue #1591 for broader context. This request now covers both supporting JSON as a native field type in Serverpod models, as well as creating expressive query interfaces for json/jsonb fields in the database. Other serializable comparisons and related operations should be discussed separately.
How experienced are you with this library?
No response
Are you interested in working on a PR for this?
- I want to work on this
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog 🗂️
Activity
[-]Support JSON field type and add query interface for json/jsonb fields (subissue of #1591)[/-][+]Support JSON field type and add query interface for json/jsonb fields[/+]exaby73 commentedon Nov 24, 2025
Some inspiration for APIs / internal packages to be used in the future when implementing this:
https://pub.dev/packages/json_path
https://pub.dev/packages/rfc_6901
https://pub.dev/packages/deep_pick
marcelomendoncasoares commentedon Nov 28, 2025
This implementation might share common interfaces with #4285.
feat: Add JSON/JSONB field type support with type-safe query interface
nicowalter256 commentedon Jun 26, 2026
is this addressed @marcelomendoncasoares