Skip to content

fix: parse JSON string where query param#15745

Merged
PatrikKozak merged 3 commits intopayloadcms:mainfrom
hugomeduarte:fix/parse-where-param-in-parseParams
Apr 9, 2026
Merged

fix: parse JSON string where query param#15745
PatrikKozak merged 3 commits intopayloadcms:mainfrom
hugomeduarte:fix/parse-where-param-in-parseParams

Conversation

@hugomeduarte
Copy link
Copy Markdown
Contributor

@hugomeduarte hugomeduarte commented Feb 24, 2026

What?

Support where sent as a JSON string in REST API requests (e.g. ?where={"read":{"equals":false}}). Previously the filter was silently ignored; now it's parsed correctly.

Why?

GET query params are always strings. parseParams parsed data this way already but skipped where, so string-encoded filters had no effect.

How?

After the data block in parseParams: if where is a non-empty string, JSON.parse it. If it's already an object (e.g. from bracket notation), leave it alone.

@hugomeduarte hugomeduarte changed the title parse where param in parseParams fix: parse where param in parseParams Feb 24, 2026
@hugomeduarte hugomeduarte changed the title fix: parse where param in parseParams fix(rest): parse where param in parseParams Feb 24, 2026
@github-actions github-actions Bot added the stale label Mar 28, 2026
@PatrikKozak PatrikKozak changed the title fix(rest): parse where param in parseParams fix: parse where param in parseParams Apr 2, 2026
@PatrikKozak PatrikKozak self-assigned this Apr 2, 2026
@PatrikKozak PatrikKozak self-requested a review April 2, 2026 16:02
@PatrikKozak PatrikKozak changed the title fix: parse where param in parseParams fix: parse JSON string where query param Apr 9, 2026
@PatrikKozak PatrikKozak merged commit 2a26b5a into payloadcms:main Apr 9, 2026
328 of 330 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.83.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
### What?

Support `where` sent as a JSON string in REST API requests (e.g.
`?where={"read":{"equals":false}}`). Previously the filter was silently
ignored; now it's parsed correctly.

### Why?

GET query params are always strings. `parseParams` parsed `data` this
way already but skipped `where`, so string-encoded filters had no
effect.

### How?

After the `data` block in `parseParams`: if `where` is a non-empty
string, `JSON.parse` it. If it's already an object (e.g. from bracket
notation), leave it alone.

---------

Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants