hasattr

Search key, in a deep json object or array

MIT License

Downloads
4
Stars
3
Committers
7

hasattr 🔎

Search key, in a deep json object or array

Installation

Using npm

npm install ak-hasattr

Using yarn

yarn add ak-hasattr

Usage

const hasAttr = require('ak-hasattr');
const JSON = {
  'name': 'Arshad Kazmi',
  'profile': {
    'github': {
      'username': 'arshadkazmi42',
      'repos': [
        {
          'repo_name': 'hasattr',
          'url': 'https://github.com/arshadkazmi42/hasattr',
        },
      ],
    },
    'twitter': {
      'username': 'arshadkazmi42',
    },
  },
};

console.log(hasAttr('name', JSON));
// true

console.log(hasAttr('repo_name', JSON));
// true

console.log(hasAttr('something', JSON));
// false

Contributing

We are constantly working on improving hasattr and we need all the help we can get.

You can contribute to this project by giving suggestions, fixing open issues or by implementing a new feature. Read our contibution guide here