Skip to main content
DevTools24

JSON a Query Builder PostgreSQL

Incolla dati JSON, seleziona visualmente i campi necessari e genera istantaneamente query PostgreSQL JSONB. Supporta notazione freccia e funzioni path.

PostgreSQL JSONB Operators

->Get JSON object field (returns JSON)
->>Get JSON object field as text
#>Get JSON at path (returns JSON)
#>>Get JSON at path as text
@>Contains (for filtering)
?Key exists check

Quando usare

  • Query JSON nidificato memorizzato in colonne PostgreSQL JSONB
  • Costruzione query estrazione complesse senza memorizzare sintassi
  • Migrazione da NoSQL a PostgreSQL con dati JSON
  • Apprendimento operatori e funzioni PostgreSQL JSONB

Suggerimenti Pro

  • Usa ->> per estrazione testo (necessario per confronti WHERE)
  • L'operatore -> restituisce JSON, mentre ->> restituisce testo
  • Gli indici GIN funzionano meglio con query containment @>
  • Le funzioni path sono più leggibili per dati profondamente nidificati

JSON to PostgreSQL Query Builder - Dettagli tecnici

PostgreSQL provides powerful JSONB support for storing and querying JSON data. The -> operator returns JSON, while ->> returns text. For nested paths, use #> and #>> or the jsonb_extract_path functions. This tool helps you build these queries visually without memorizing the syntax.

Alternativa da riga di comando

-- Arrow notation
SELECT data->'user'->>'name' FROM users;

-- Path function
SELECT jsonb_extract_path_text(data, 'user', 'name') FROM users;

-- Containment query (uses GIN index)
SELECT * FROM users WHERE data @> '{"status": "active"}';

Riferimento

Visualizza specifica ufficiale