Skip to main content
DevTools24

Construtor de Queries JSON para PostgreSQL

Cole dados JSON, selecione visualmente os campos que precisa e gere queries PostgreSQL JSONB instantaneamente. Suporta notação de seta e funções de caminho.

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 Usar

  • Consultar JSON aninhado armazenado em colunas PostgreSQL JSONB
  • Construir queries de extração complexas sem memorizar sintaxe
  • Migrar de NoSQL para PostgreSQL com dados JSON
  • Aprender operadores e funções PostgreSQL JSONB

Dicas Profissionais

  • Use ->> para extração de texto (necessário para comparações WHERE)
  • O operador -> retorna JSON, enquanto ->> retorna texto
  • Índices GIN funcionam melhor com queries de contenção @>
  • Funções de caminho são mais legíveis para dados profundamente aninhados

JSON to PostgreSQL Query Builder - Detalhes Técnicos

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 via Linha de 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"}';

Referência

Ver Especificação Oficial