1.0.0 • Published 5 years ago

json-data-paths v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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' ]
*/