jsonb_set for nested new item? - Mailing list pgsql-general

From Deven Phillips
Subject jsonb_set for nested new item?
Date
Msg-id CAJw+4NA7y-baCDJPkR-0MvxcrUW9qJbGb71MHzJYKs180mz+Sw@mail.gmail.com
Whole thread Raw
Responses Re: jsonb_set for nested new item?  (Deven Phillips <deven.phillips@gmail.com>)
Re: jsonb_set for nested new item?  (René Leonhardt <rene.leonhardt@gmail.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Dorian Hoxha
Date:
Subject: Re: Multiple inserts
Next
From: Deven Phillips
Date:
Subject: Re: jsonb_set for nested new item?