Re: jsonb_set for nested new item?

From: Deven Phillips <deven(dot)phillips(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: jsonb_set for nested new item?
Date: 2016-09-23 14:19:12
Message-ID: CAJw+4NAJ0wpCxUrbiKoBpXW7rr=e3uny4pvaEY5yGc+_Lw8niA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Actually, it looks like I have to create all of the parent objects first
before it would work... Is that correct?

Deven

On Fri, Sep 23, 2016 at 10:14 AM, Deven Phillips <deven(dot)phillips(at)gmail(dot)com>
wrote:

> Is there a way to set a nested element for which the parent paths do not
> yet exist?
>
> For example, if I have a JSONB value called 'data':
>
> {
> "foo": "bar"
> }
>
> and run
>
> jsonb_set(data, {'boo', 'baz'}, 'newvalue')
>
> I would expect the output to be:
>
> {
> "foo": "bar",
> "boo": {
> "baz": "newvalue"
> }
> }
>
> But that does not appear to work..
>
> Any suggestions would be appreciated.
>
> Deven
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Арсен Арутюнян 2016-09-23 15:44:02 Transactions and functions
Previous Message Deven Phillips 2016-09-23 14:14:57 jsonb_set for nested new item?