From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: mogrify and indent features for jsonb |
Date: | 2015-02-23 17:51:44 |
Message-ID: | CAA-aLv5GmXE6w8zZj_P-h0pkdD99ZE=3=N=OWFJ+Mnc0EgxUbw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 15 February 2015 at 03:06, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> Attached is a patch to provide a number of very useful facilities to jsonb
> that people have asked for. These are based on work by Dmitry Dolgov in his
> jsonbx extension, but I take responsibility for any bugs.
>
> The facilities are:
>
> new operations:
>
> concatenation: jsonb || jsonb -> jsonb
> deletion: jsonb - text -> jsonb
> deletion: jsonb - int -> text
>
> new functions:
>
> produce indented text: jsonb_indent(jsonb) -> text
> change an element at a path: jsonb_replace(jsonb, text[], jsonb) -> jsonb.
>
>
> It would be relatively trivial to add:
>
> delete an element at a path: jsonb_delete(jsonb, text[]) -> json
>
Would this support deleting "type" and the value 'dd' from the following?:
{"a": 1, "b": 2, "c": {"type": "json", "stuff": "test"}, "d":
["aa","bb","cc","dd"]}
>
> and I think we should do that for the sake of completeness.
>
> The docs might need a little extra work, and the indent code definitely
> needs work, which I hope to complete in the next day or two, but I wanted
> to put a stake in the ground.
>
This is high on my wanted list, so thanks for working on this.
Seems to work well for me with a few tests.
Is there a way to take the json:
'{"a": 1, "b": 2, "c": {"type": "json", "stuff": "test"}, "d":
["aa","bb","cc","dd"]}'
and add "ee" to "d" without replacing it? I can think of ways of currently
doing it, but it's very convoluted just for pushing a value to an array.
Also, are there any plans to support the following?:
jsonb - text[] # Provide list of keys to delete in array
jsonb - jsonb # Deduplicate key:value pairs
jsonb && jsonb # Return overlapping jsonb (opposite of jsonb - jsonb)
Thanks
Thom
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2015-02-23 17:52:26 | Re: [RFC] LSN Map |
Previous Message | Henry B Hotz | 2015-02-23 17:38:38 | Re: SSL renegotiation |