Re: json accessors

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: json accessors
Date: 2012-12-04 02:52:46
Message-ID: 50BD657E.2030102@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 12/03/2012 08:14 PM, Josh Berkus wrote:
> Andrew,
>
> What about doing:
>
> json_get(json, json)
> returns json
>
> where parameter #2 is a path expressed as JSON? For example,
>
> json_get(personal_profile, '[ {contact_info {phone numbers {cell phones}
> } } ]')
> ... would return whatever was in that heirarchical object, in this case
> an array of cell phone numbers.
>
> Or am I just reinventing jsonpath?
>

Yes, you are, rather. It might be possible to do something like:

json_get(json, variadic text) => json

as long as it doesn't involve any testing beyond field name / array
index equivalence.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2012-12-04 03:06:11 Re: Tablespaces in the data directory
Previous Message Tom Lane 2012-12-04 02:44:33 Re: ALTER TABLE ... NOREWRITE option