Skip to content

2.10.0 - SQL functions for JSON extraction

Compare
Choose a tag to compare
@OndraZizka OndraZizka released this 02 Dec 21:17
· 18 commits to master since this release

A couple of SQL functions are now added:

  • jsonSubtree(path, json) - Returns a json subtree (as JSON) at a given slash-separated path (foo/bar). Arrays not supported, but could be added.

  • jsonLeaf(path, json) - Like above, but expects the node to be a scalar, and returns the raw value rather than JSON serialization of it.

  • jsonLeaves(pathToArray LONGVARCHAR, leavesSubpath LONGVARCHAR, json LONGVARCHAR, nullOnNonArray BOOLEAN) - returns the leaves form an array, extracted from the given subpath (of each item in that array). Returns it serialized to JSON - due to limitations of HSQLDB. Expects the leaves to be scalar.

  • jsonSubtrees(pathToArray, subpath, json) - Not implemented. It would do the same as jsonLeaves(), except it would put the sub-nodes (rather than only scalars) to an array of subtrees. Let me know if you need it.

The reason why jsonSubtrees is missing is that originally, jsonLeaves() was supposed to return a SQL type ARRAY, but that is not supported by HSQLDB.