Re: json accessors - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: json accessors
Date
Msg-id 50BD657E.2030102@dunslane.net
Whole thread Raw
In response to Re: json accessors  (Josh Berkus <josh@agliodbs.com>)
Responses Re: json accessors
List 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




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ALTER TABLE ... NOREWRITE option
Next
From: Bruce Momjian
Date:
Subject: Re: Tablespaces in the data directory