1.0.2 • Published 1 year ago

jsonkeyfinder v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

jsonkeyfinder

npm version License: MIT

Description

jsonkeyfinder is a lightweight npm package that provides a function to find the value of any key from deep levels of JSON. It's useful for traversing complex JSON structures and retrieving specific values efficiently.

Installation

You can install jsonkeyfinder via npm:

npm install jsonkeyfinder

Usage

import { findValueByKey } from 'jsonkeyfinder';

const jsonObject = {
  "foo": {
    "bar": {
      "baz": "value"
    }
  }
};

const value = findValueByKey(jsonObject, 'baz');
console.log(value); // Output: "value"

API

findValueByKey(json: JsonObject, key: string): any

  • json: The JSON object to search within.
  • key: The key to search for within the JSON object.
  • Returns the value associated with the specified key. Returns undefined if the key is not found.

Example

import { findValueByKey } from 'jsonkeyfinder';

const jsonObject = {
  "name": "John Doe",
  "age": 30,
  "address": {
    "city": "New York",
    "zip": 10001
  }
};

const age = findValueByKey(jsonObject, 'age');
console.log(age); // Output: 30

License

This package is licensed under the MIT License. See the LICENSE file for details.

Author

Created by abhijeet_vadera.

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago