mattbishop / sql-jsonpath-js

JS implementation of the SQL/JSONPath dialect, from SQL2016.
MIT License
0 stars 0 forks source link

SqlJsonPath interface that matches spec #10

Closed mattbishop closed 1 year ago

mattbishop commented 2 years ago

The spec has these methods defined:

JSON_EXISTS returns true, false, undefined or throws an Error.

JSON_VALUE returns a scalar value or undefined if not found. It cannot extract arrays or objects, only values. When it references an array, it uses the normal SQL JSONPath array-unwrapping logic. One can declare a default value when an undefined is encountered.

Not sure how useful this is outside of SQL, where this method is used to populate column values from json objects.

JSON_QUERY extracts JS values from JSON. It has an array wrapper flag that will wrap values in an array if not already an array. It has conditional and unconditional features. It has no default value feature but one can specify an empty object or array instead of undefined as a result.

JSON_TABLE is quite complex and generates tables from JSON. It has features to describe join plans. This one can be left off the JS API.

mattbishop commented 1 year ago

exists(), values() and query() are implemented.