From: Dave Ekhaus <dave.ekhaus@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: JSON question
Date: Mon, 4 Apr 2022 21:45:06 -0700
Message-ID: <1362aceb-cc4a-45f4-b57d-0b56b878ca83@Canary> (raw)
Hi All
I'm experimenting with PostgreSQL's JSON features and have a question.
Say we have the following JSON (which will be stored in a table named 'resources' - in its 'schema' column ...
{
"name": {
"type": "string",
"label": "Name",
"accessor": "name",
"is_association": false
},
"books": {
"type": "array",
"label": "Books",
"accessor": "books",
"is_association": true
},
"email": {
"type": "string",
"label": "Email",
"accessor": "email",
"is_association": false
},
"date_of_birth": {
"type": "date",
"label": "Birthday",
"accessor": "date_of_birth",
"is_association": false
}
}
[NOTE: the JSON above is the 'schema' attribute of one record in the 'resources' table. There will be many rows in the 'resources' table]
How can I query the 'resources' table to return the rows in which there's at least one JSON object whose 'type' equals 'array' ?
Thanks
Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: dave.ekhaus@gmail.com
Subject: Re: JSON question
In-Reply-To: <1362aceb-cc4a-45f4-b57d-0b56b878ca83@Canary>
References: <1362aceb-cc4a-45f4-b57d-0b56b878ca83@Canary>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox