Re: json accessors - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: json accessors
Date
Msg-id 50B8D7F0.5040603@2ndQuadrant.com
Whole thread Raw
In response to Re: json accessors  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: json accessors  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
On 11/30/2012 04:29 PM, Andrew Dunstan wrote:
>
> On 11/30/2012 10:04 AM, Hannu Krosing wrote:
>>>
>>>
>>> OK, so based on this discussion, I'm thinking of the following:
>>>
>>>  * keep the original functions and operators. json_keys is still
>>>    required for the case where the json is not flat.
>>>  * json_each(json) => setof (text, text)
>>>    errors if the json is not a flat object
>>
>> Why not json_each(json) => setof (text, json) ? with no erroring out ?
>>
>> if the json does represent text it is easy to convert to text on the 
>> query side.
>
>
> Well, it would be possible, sure. I'm not sure how useful. Or we could 
> do both fairly easily. It's not as simple or efficient as you might 
> think to dequote / de-escape json string values, which is why the 
> original API had variants for returning both types of values. Maybe we 
> need a function for doing just that.
>
Btw, how does current json type handle code pages - is json always utf-8 
even when server encoding is not ?

if so then we could at least have a shortcut conversion of json to 
utf8-text which can skip codepage changes.

----------------------
Hannu




pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: missing LockBuffer(buffer, BUFFER_LOCK_SHARE) in trigger.c GetTupleForTrigger?
Next
From: Tatsuo Ishii
Date:
Subject: Re: [PATCH] Patch to fix a crash of psql