json-data-paths

1.0.0 • Public • Published

JSON DATA PATHS

Easily extract complete paths to every property in an object.

Created for use with Simple Object Path

const jsonDataPaths = require('./index')
const obj = {animal:
  {
      type: 'Feline',
      dailyNeeds: [
          {timeOfDay: 'morning', need: 'Breakfast'},
          {timeOfDay: 'evening', need: 'Dinner'}
      ]
  }
}

const paths = jsonDataPaths(obj)
/*
[ 'animal',
  'animal/type',
  'animal/dailyNeeds',
  'animal/dailyNeeds/0',
  'animal/dailyNeeds/0/timeOfDay',
  'animal/dailyNeeds/0/need',
  'animal/dailyNeeds/1',
  'animal/dailyNeeds/1/timeOfDay',
  'animal/dailyNeeds/1/need' ]
*/

Readme

Keywords

none

Package Sidebar

Install

npm i json-data-paths

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.21 kB

Total Files

5

Last publish

Collaborators

  • joshsteverson