| name | postgresql-json |
| description | Work with JSONB data - queries, indexing, transformations |
| version | 3.0.0 |
| sasmp_version | 1.3.0 |
| bonded_agent | 05-postgresql-advanced |
| bond_type | PRIMARY_BOND |
| category | database |
| difficulty | intermediate |
| estimated_time | 2h |
PostgreSQL JSON Skill
Atomic skill for JSONB operations
Overview
Production-ready patterns for JSONB queries, indexing, and transformations.
Prerequisites
- PostgreSQL 16+
- Understanding of JSON structure
Parameters
parameters:
operation:
type: string
required: true
enum: [query, index, transform, aggregate]
json_path:
type: string
Quick Reference
JSONB Operators
| Operator | Description | Example |
|---|
-> | Get object | data->'user' |
->> | Get as text | data->>'name' |
@> | Contains | data @> '{"active":true}' |
? | Key exists | data ? 'email' |
Index Patterns
CREATE INDEX idx_data ON t USING GIN(data);
CREATE INDEX idx_data_path ON t USING GIN(data jsonb_path_ops);
CREATE INDEX idx_status ON t ((data->>'status'));
Common Operations