🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

data-path-finder

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
d

data-path-finder

Library and CLI tool to find properties of a JSON data structure using datapath string

0.0.4
latest

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Version published
Maintainers
2
Created
Issues
0

data-path-finder

This library allows for traversing a javascript object to find particular properties specified in a data-path string.

A data-path string provides the ability to specify an object-traversal mechanism to grab specific attribute values out of the provided object.

Data Path specification

A data-path string conforms to a simple specification of a property tree.

Consider the following javascript object:

{
  userName:"Jose",
  address: "San Pablo de Heredia",
  favoriteCars: [ 
    {
      make:"Nissan",
      model:"versa"
    },
    {
      make:"Toyota",
      model:"Rav4"
    },
    {
      make:"Hyundai",
      model:"Santa Fe"
    }
  ]
}

The data-path specification "userName" points to the value "Jose", while the data-path specification "favoriteCars[].make" point to the value ["Nissan","Toyota","Hyundai"]

Uses of this library

Known uses for data-path expressions implemented in this library include data transformation, mapping and verification out of dynamic rules specified in text. For example for comparing two objects of different structure that may have common attributes.

Example using the cli.js file

  • In an empty directory, run npm install data-path-finder
  • Then run cd node_modules/data-path-finder/src
  • Then run `node cli.js "../es_samples/favoriteCars.json" "favoriteCars[].make"
  • The command should display a result of ["Nissan","Toyota","Hyundai"]

FAQs

Package last updated on 17 Oct 2020

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