Skip to content

staeco/jsonstream-paths

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonstream-paths NPM version Downloads Build Status

Install

npm install jsonstream-paths --save

Example

const sample = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: {
        name: 'Downtown',
        operators: [
          'Jersey City Department of Innovation'
        ]
      },
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [
              -74.05208945274353,
              40.72912064182603
            ],
            [
              -74.05428886413574,
              40.72293316385307
            ]
          ]
        ]
      }
    },
    {
      type: 'Feature',
      properties: {
        name: 'The Heights',
        operators: [
          'Jersey City Department of Innovation'
        ]
      },
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [
              -74.04601693153381,
              40.750743837352594
            ],
            [
              -74.05118823051453,
              40.743300479884844
            ]
          ]
        ]
      }
    },
    {
      type: 'Feature',
      properties: {
        name: 'Stae Field (Brooklyn)',
        operators: [
          'Stae'
        ]
      },
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [
              -73.9552965760231,
              40.72180496443893
            ],
            [
              -73.95569890737534,
              40.72141872961497
            ]
          ]
        ]
      }
    }
  ]
}
const stream = get()
stream.write(JSON.stringify(sample))
stream.on('data', (path) => {
  // each data event is a string path
})
/*
  Results:
  'features.*.type',
  'features.*.properties.name',
  'features.*.properties.operators.*',
  'features.*.properties.operators',
  'features.*.properties',
  'features.*.geometry.type',
  'features.*.geometry.coordinates.*.*.*',
  'features.*.geometry.coordinates.*.*',
  'features.*.geometry.coordinates.*',
  'features.*.geometry.coordinates',
  'features.*.geometry',
  'features.*',
  '*'
*/

About

Get all possible paths for JSONStream

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published