Re: JsonbValue to Jsonb conversion

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: JsonbValue to Jsonb conversion
Date: 2014-09-24 00:20:15
Message-ID: 54220E3F.2060107@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 09/23/2014 12:23 PM, Dmitry Dolgov wrote:
> Hi all,
>
> I'm faced with some troubles about the jsonb implementation, and I
> hope I'll get little advice =)
> If I understand correctly, an abstract function for jsonb modification
> should have the following stages:
>
> Jsonb -> JsonbValue -> Modification -> JsonbValue -> Jsonb
>
> One can convert the *JsonbValue* to the *Jsonb* only by
> *JsonbValueToJsonb* function. So, my question is can be *JsonbValue*,
> that contains few *jbvBinary* elements, converted to *Jsonb* by this
> function? It will be very useful, if you want modify only small part
> of your JsonbValue (e.g. replace value of some key). But when I'm
> trying to do this, an exception "unknown type of jsonb container"
> appears. Maybe I missed something? Or is there another approach to do
> this conversion?

If you can come up with a way of handling the jbvBinary values then by
all means send a patch.

But this problem is fairly easily worked around by using an iterator
over the binary value. The attached patch, which is work in progress for
adding in the currently missing json functions for jsonb, contains a
sort of example of doing this in jsonb_agg_transfn.

cheers

andrew

Attachment Content-Type Size
jsonbmissingfuncs.patch text/x-patch 37.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2014-09-24 00:51:39 Re: jsonb format is pessimal for toast compression
Previous Message Michael Paquier 2014-09-24 00:02:57 Re: "Core" function in Postgres