Re: mogrify and indent features for jsonb

From: Thom Brown <thom(at)linux(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: mogrify and indent features for jsonb
Date: 2015-02-25 11:13:07
Message-ID: CAA-aLv4J=1ew_Do1MRKjMQVQpnNMS=wspaWjHS2hymuaFeoxTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24 February 2015 at 19:16, Josh Berkus <josh(at)agliodbs(dot)com> wrote:

>
> > 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.
>
> Can you think of a reasonable syntax for doing that via operators? I
> can imagine that as a json_path function, i.e.:
>
> jsonb_add_to_path(jsonb, text[], jsonb)
>
> or where the end of the path is an array:
>
> jsonb_add_to_path(jsonb, text[], text|int|float|bool)
>
> But I simply can't imagine an operator syntax which would make it clear
> what the user intended.
>

No, there probably isn't a sane operator syntax for such an operation. A
function would be nice. I'd just want to avoid hacking away at arrays by
exploding them, adding a value then re-arraying them and replacing the
value.

--
Thom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2015-02-25 11:18:57 Re: Dereferenced pointer checks in data.c of ECPG
Previous Message Andres Freund 2015-02-25 11:10:42 Re: Merge compact/non compact commits, make aborts dynamically sized