
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
nested-prop-resolver
Advanced tools
"This library helps you to find and get a nested property from a complex json object. It protects your code from null or undefined errors"
This library helps you to find and get a nested property from a complex json object without any runtime error. You can use this to resolve json properties from an api response.
eg:
const responseObj = {
user: {
name: 'Hiran'
}
};
const officeAddress = responseObj.office.address; // This will give you a runtime error since there is no 'office' property in api response object.
So, use the 'nested-prop-resolver' to prevent runtime errors.
// With the default value
const officeAddress = resolve(responseObj, 'office.address', 'N/A'); // Output is 'N/A'. No runtime error.
// Without the default value
const officeAddress = resolve(responseObj, 'office.address'); // Output is 'undefined'. No runtime error.
// Note: Default value is optional
const userName = resolve(responseObj, 'user.name'); // Output is 'Hiran'.
yarn nested-prop-resolver
or
npm install nested-prop-resolver --save
import { resolve } from 'nested-prop-resolver';
// For nested props
const responseObj = {
user: {
name: 'Hiran'
}
};
const name = resolve(responseObj, 'user.name'); // Output is 'Hiran'.
// For nested arrays
const responseObj = {
users: [
{
name: 'Hiran'
}
]
};
const name = resolve(responseObj, 'users[0].name'); // Output is 'Hiran'.
// For complex nested arrays
const responseObj = [
{
users: [
{
name: 'Hiran'
}
]
}
];
const name = resolve(responseObj, '[0].users[0].name'); // Output is 'Hiran'.
// For unpresent nested props.
const responseObj = {
user: {
name: 'Hiran'
}
};
// With default value
const age = resolve(responseObj, 'user.age', 'Not Given'); // Output is 'Not Given'.
// Without default value.
const age = resolve(responseObj, 'user.age'); // Output is 'undefined'.
MIT © H.R. Hiran Peiris
FAQs
"This library helps you to find and get a nested property from a complex json object. It protects your code from null or undefined errors"
We found that nested-prop-resolver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.