Registry / database / sql-jsonpath-js

sql-jsonpath-js

JSON →
library1.0.1jsnpmunverified

JavaScript implementation of the SQL/JSONPath dialect from SQL2016, version 1.0.1. Provides exists() and values() methods for querying JSON data, similar to JavaScript's RegExp. Includes TypeScript definitions. Suitable for streaming data with lazy iterator support. Differentiated from other JSONPath libraries by strict adherence to the SQL standard and iterator-based API.

npm install sql-jsonpath-js
INSTALL
IMPORT
SIG · SQL-JSONPATH-JS
S
sql-jsonpath-js
databasejavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'sql-jsonpath-js'
import sqlJsonPath from 'sql-jsonpath-js'
The library uses named exports; default import is not available.
SqlJsonPathStatement
import { SqlJsonPathStatement } from 'sql-jsonpath-js'
const { SqlJsonPathStatement } = require('sql-jsonpath-js')
Library is ESM-only in v1.0.1; CommonJS require is not supported.
one
import { one } from 'sql-jsonpath-js'
Utility to extract first value from iterator, returns null if empty.

Demonstrates compiling a JSONPath, checking existence, and extracting a value with the one() helper.

import { compile, one } from 'sql-jsonpath-js'; const statement = compile('$.name'); const data = { name: 'Alice' }; console.log(statement.exists(data)); // true const value = one(statement.values(data)); console.log(value); // 'Alice'
Debug
Known issues
gotchaArray input to values() or exists() is treated as a single object, not an iterable. Use [Symbol.iterator]() to iterate over array elements.
fix
Call data[Symbol.iterator]() when passing arrays as iterables.
affects: >=1.0.0
gotchavalues() returns an iterator; results must be consumed via next() or Array.from(). one() returns null on empty results.
fix
Use one() for single expected result or iterate properly.
affects: >=1.0.0
gotchaexists() on an iterator returns an iterator of booleans; on a single value it returns a boolean. This dual behavior can be confusing.
fix
Check input type: if using with iterators, expect iterator result.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: sjp.compile is not a function
Importing default export instead of named export.
fix
Use import { compile } from 'sql-jsonpath-js'
TypeError: statement.values is not a function
Statement not compiled properly or imported incorrectly.
fix
Ensure compile() returns a SqlJsonPathStatement object.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
16
Meta
2
OpenAI (training)
1
Resources
sql-jsonpath-js — npm install sql-jsonpath-js · libregistry