json-patch support?

Started by Deven Phillipsabout 11 years ago5 messagesgeneral
Jump to latest
#1Deven Phillips
deven.phillips@gmail.com

Are there any plans or ideas about implement JSON Patch (
http://jsonpatch.com/) support for PostgreSQL? We deal with some relatively
large JSON documents for our in-house application and it is often better to
just send a json-patch update rather than the full document. It would be
very nice if we could just select for the changes via a trigger and use
NOTIFY to tell our application about a patch. If nobody has discussed it
previously, perhaps I will look into implementing it myself.

Thanks in advance,

Deven

#2Arthur Silva
arthurprs@gmail.com
In reply to: Deven Phillips (#1)
Re: json-patch support?

On Fri, Mar 27, 2015 at 1:56 PM, Deven Phillips <deven.phillips@gmail.com>
wrote:

Are there any plans or ideas about implement JSON Patch (
http://jsonpatch.com/) support for PostgreSQL? We deal with some
relatively large JSON documents for our in-house application and it is
often better to just send a json-patch update rather than the full
document. It would be very nice if we could just select for the changes via
a trigger and use NOTIFY to tell our application about a patch. If nobody
has discussed it previously, perhaps I will look into implementing it
myself.

Thanks in advance,

Deven

This could be implemented as an extension.
There're already a few extensions that provide this functionality with
plain functions, so it's just a matter of parsing the json and executing
those functions.

#3Merlin Moncure
mmoncure@gmail.com
In reply to: Arthur Silva (#2)
Re: json-patch support?

On Fri, Mar 27, 2015 at 1:36 PM, Arthur Silva <arthurprs@gmail.com> wrote:

On Fri, Mar 27, 2015 at 1:56 PM, Deven Phillips <deven.phillips@gmail.com>
wrote:

Are there any plans or ideas about implement JSON Patch
(http://jsonpatch.com/) support for PostgreSQL? We deal with some relatively
large JSON documents for our in-house application and it is often better to
just send a json-patch update rather than the full document. It would be
very nice if we could just select for the changes via a trigger and use
NOTIFY to tell our application about a patch. If nobody has discussed it
previously, perhaps I will look into implementing it myself.

Thanks in advance,

Deven

This could be implemented as an extension.
There're already a few extensions that provide this functionality with plain
functions, so it's just a matter of parsing the json and executing those
functions.

Right. If it was me, I'd shoot for a userland (that is, in sql or
pl/pgsql) implementation that wraps the existing json APIs to get the
desired result. From there, could determine if a more optimized
version in C was warranted.

merlin

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Deven Phillips
deven.phillips@gmail.com
In reply to: Merlin Moncure (#3)
Re: json-patch support?

OK, then I will look into perhaps implementing it as a pl-python or pl-java
function. Thanks for the advice!!

Deven

On Fri, Mar 27, 2015 at 2:40 PM, Merlin Moncure <mmoncure@gmail.com> wrote:

Show quoted text

On Fri, Mar 27, 2015 at 1:36 PM, Arthur Silva <arthurprs@gmail.com> wrote:

On Fri, Mar 27, 2015 at 1:56 PM, Deven Phillips <

deven.phillips@gmail.com>

wrote:

Are there any plans or ideas about implement JSON Patch
(http://jsonpatch.com/) support for PostgreSQL? We deal with some

relatively

large JSON documents for our in-house application and it is often

better to

just send a json-patch update rather than the full document. It would be
very nice if we could just select for the changes via a trigger and use
NOTIFY to tell our application about a patch. If nobody has discussed it
previously, perhaps I will look into implementing it myself.

Thanks in advance,

Deven

This could be implemented as an extension.
There're already a few extensions that provide this functionality with

plain

functions, so it's just a matter of parsing the json and executing those
functions.

Right. If it was me, I'd shoot for a userland (that is, in sql or
pl/pgsql) implementation that wraps the existing json APIs to get the
desired result. From there, could determine if a more optimized
version in C was warranted.

merlin

#5Deven Phillips
deven.phillips@gmail.com
In reply to: Deven Phillips (#4)
Re: json-patch support?

Finally got around to doing this... The link below points to a complete
implementation of JSONPatch in pure PostgreSQL. It is compatible with
PostgreSQL >= 9.5 (Not tested using earlier versions)

https://gist.github.com/InfoSec812/b830a9db4c9048552f8c51d7987cc4d0

Cheers!

Deven

On Fri, Mar 27, 2015 at 4:16 PM, Deven Phillips <deven.phillips@gmail.com>
wrote:

Show quoted text

OK, then I will look into perhaps implementing it as a pl-python or
pl-java function. Thanks for the advice!!

Deven

On Fri, Mar 27, 2015 at 2:40 PM, Merlin Moncure <mmoncure@gmail.com>
wrote:

On Fri, Mar 27, 2015 at 1:36 PM, Arthur Silva <arthurprs@gmail.com>
wrote:

On Fri, Mar 27, 2015 at 1:56 PM, Deven Phillips <

deven.phillips@gmail.com>

wrote:

Are there any plans or ideas about implement JSON Patch
(http://jsonpatch.com/) support for PostgreSQL? We deal with some

relatively

large JSON documents for our in-house application and it is often

better to

just send a json-patch update rather than the full document. It would

be

very nice if we could just select for the changes via a trigger and use
NOTIFY to tell our application about a patch. If nobody has discussed

it

previously, perhaps I will look into implementing it myself.

Thanks in advance,

Deven

This could be implemented as an extension.
There're already a few extensions that provide this functionality with

plain

functions, so it's just a matter of parsing the json and executing those
functions.

Right. If it was me, I'd shoot for a userland (that is, in sql or
pl/pgsql) implementation that wraps the existing json APIs to get the
desired result. From there, could determine if a more optimized
version in C was warranted.

merlin