Manipulating jsonb

From: Andreas Heiduk <asheiduk(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Manipulating jsonb
Date: 2014-05-02 18:32:53
Message-ID: CAFhHFBxne_ysYMQaXmND93umD02FYk=+h+nq7zGCPqGLjBJqUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm playing with a 9.4 preview and the upcoming jsonb datatype. But
I'm missing the basic modification syntax.

Given the following situation:

CREATE TABLE test(key int, jsonval jsonb);
INSERT INTO test VALUES(1, '{"a": 1, "c": 3}');

How can I UPDATE that row with '{"b": 2, "d": 4}' ? Something like
this does not work:

UPDATE test SET jsonval = jsonval || '{"a": 1, "c": 3}'::jsonb
where key = 1;

The result should be

{"a": 1, "b": 2, "c": 3, "d": 4}

The same goes for removing values.

Did I overlook something obvious or is there really no way to do that right now?

Best regards,
Andreas Heiduk

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2014-05-02 19:13:02 Re: Vacuuming strategy
Previous Message gvim 2014-05-02 17:46:35 Timeouts after upgrade from 9.0 to 9.3