Socket
Book a DemoInstallSign in
Socket

@saasquatch/jsonata-paths-extractor

Package Overview
Dependencies
Maintainers
11
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saasquatch/jsonata-paths-extractor

A package for statically analysing JSONata expressions and returning object paths from the context that are likely used. Complete static analysis of JSONata is not attempted (and may not actually be feasible), so the results are considered best-effort.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
11
Created
Source

JSONata Paths Extractor

A package for statically analysing JSONata expressions and returning object paths from the context that are likely used. Complete static analysis of JSONata is not attempted (and may not actually be feasible), so the results are considered best-effort.

Installation

Using npm or yarn the package can be installed

npm i @saasquatch/jsonata-paths-extractor

Usage

A single function is exported as the default export. The function accepts a JSONata expression as input and returns the paths found in the expression.

For more detail on behaviour, see test/paths.feature

Example usage:

import extractJSONataPaths from "@saasquatch/jsonata-paths-extractor";

const exampleJsonataExpression =
  'example.jsonata.path = "a string" ? example.two : example[two="test"].name^(<three)';

const paths = extractJSONataPaths(exampleJsonataExpression);
// paths: ["/example/jsonata/path","/example/two","/example/name","/example/two","/example/name/three"]

Test Suite

The package contains a test suite that runs through expressions sourced from program conditions and the JSONata test suite. The results of these tests were autogenerated and reviewed, they should be used as a set of tests to ensure against regressions. The results of the test suite should only be modified after implementing improvements to the library.

Improvements should be documented in the feature file in addition to the automated tests.

FAQs

Package last updated on 20 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts