There is an XQuery module in the "versioning" prefixed namespace that allows you to perform various queries over versions.
The versioning module was removed from the eXist codebase after eXist 2.2 as it was found to contain GPL licensed code, which is incompatible with eXist's LGPL license.
The code for the versioning module can now be found here: https://bitbucket.org/zwobit/versioning/src/7e177a5f3cf8ad6980a502eb5a0c20cf136e7a7c/src/main/java/org/exist/versioning/xquery/?at=develop
If you look at the versioning.xqm
, DiffFunction.java
and PatchFunction.java
, you can see the functions that are available for you to call from XQuery.
As far as I recall though, you cannot get a diff between JSON documents as eXist only provides diffs for XML documents. Instead the versioning module treats the JSON documents as binary, and therefore immutable, each change to the document generates an entirely new document (which may be what you need).
There is nothing to stop you invoking GNU diff from XQuery (via the process module) and passing both JSON documents through it.