---
title: JSON Query Syntax
description: How to write text search queries as JSON
canonical: https://docs.paradedb.com/documentation/query-builder/json
---

ParadeDB also supports writing query builder functions as JSON objects.
This is useful for programmatic generation or client applications that construct search queries as structured JSON.

To write a query as JSON, first call `SELECT` on the desired query builder function, which returns its JSON
representation:

```sql
SELECT pdb.regex('key.*');
```

<Accordion title="Expected Response">
```csv
             regex
-------------------------------
 {"regex":{"pattern":"key.*"}}
(1 row)
```
</Accordion>

Next, paste this JSON string into the right-hand side of the `@@@` operator and cast it to `pdb.query`:

```sql
SELECT description, rating, category
FROM mock_items
WHERE description @@@
'{
    "regex": {
        "pattern": "key.*"
    }
}'::pdb.query;
```

<Note>
  The JSON query object must be explicitly cast to `pdb.query` using
  `::pdb.query`.
</Note>
