Skip to content

object-scan

185 8 17 MIT
20.0.4 (10 Dec 2025) Jun 10 2018 191.8 thousand (month)

object-scan allows traversal of complex javascript objects to find specific keys.

In web scraping, it's useful for parsing large, nested JSON datasets for specific datafields. object-scan can be used to recursively find any key in any object structure:

import objectScan from 'object-scan';

const haystack = { a: { b: { c: 'd' }, e: { f: 'g' } } };
objectScan(['a.*.f'], { joined: true })(haystack);
// => [ 'a.e.f' ]

Example Use


const objectScan = require('object-scan');

const myNestedObject = {
  level1: {
    level2: {
      level3: {
        myTargetKey: 'value',
      },
    },
  },
};

const searchTerm = 'myTargetKey';
const result = objectScan([`**.${searchTerm}`], { joined: false })(myNestedObject);
console.log(result);

Alternatives / Similar


Other Languages

2,457 1.1.0 (2026-01-22 16:35:24 ago) Feb 09 2022 compare
739 1.16.0 (2026-11-04 14:37:00 ago) Feb 09 2022 compare
2,404 0.2.29 (2026-11-23 05:54:04 ago) May 19 2011 compare
204 0.2.25 (2022-07-06 18:55:03 ago) Feb 09 2022 compare
1,776 4.0.0 (2021-03-24 12:37:03 ago) Apr 18 2015 compare
Was this page helpful?