Socket
Book a DemoInstallSign in
Socket

data-path-finder

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-path-finder

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

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
2
Created
Source

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"]

Keywords

util

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.