Re: JSON NULLs - Mailing list pgsql-hackers

From Yeb Havinga
Subject Re: JSON NULLs
Date
Msg-id 5118AA09.6000104@gmail.com
Whole thread Raw
In response to Re: JSON NULLs  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: JSON NULLs
List pgsql-hackers
On 2013-02-10 16:03, Andrew Dunstan wrote:
> On 02/10/2013 05:43 AM, Yeb Havinga wrote:
>> 3. I was wondering how to access the first author from this json 
>> snippet:
>>
>> {
>>  "id": "QZr82w_eSi8C",
>>  "etag": "KZ+JsrkCdqw",
>>  "volumeInfo": {
>>   "title": "Heads Up Software Construction",
>>   "authors": [
>>    "Dan Malone",
>>    "Dave Riles"
>>   ],
>>
>>
>
> try:
>
>    json_get_path_as_text(document,  'volumeInfo', 'authors', '0')
>
>
> There are other ways to spell this, too:
>
>    json_get_path_as_text(document,  variadic
>    '{volumeInfo,authors,0}'::text[])
>
>
> or
>
>    document->>'{volumeInfo,authors,0}'::text[]

That works very nice, thanks!
>
> I'm actually wondering if we should use different operator names for 
> the get_path*op functions so we wouldn't need to type qualify the path 
> argument. Maybe ?> and ?>> although I'm reluctant to use ? in an 
> operator given the recent JDBC discussion. Or perhaps #> and #>>.

different operator name: +1.

thanks
Yeb




pgsql-hackers by date:

Previous
From: Jeevan Chalke
Date:
Subject: Re: unlogged tables vs. GIST
Next
From: Pavan Deolasee
Date:
Subject: Re: Too frequent checkpoints ?