Give a dotted path, return the value somewhere in a json object
npm install @empreintes/pathmapreturn value somewhere in a json object, from a dotted string path
npm install @empreintes/pathmath
# or
yarn add @empreintes/pathmath
---
const { PathMap } = require("@empreintes/pathmap")
const data = {
data: [
{
id: 47179,
stuff: {
id: 2
}
}
...
]
foo : {
bar : true
}
}
const pathMap = new PathMap(data)
pathMap.path("data#0.stuff.id") // 2
pathMap.path("data#0.id") // 47179
pathMap.path("foo.bar") // true
Version 0.0.4 includes important security improvements:
- 🔒 Prototype pollution prevention - Rejects dangerous keys (__proto__, constructor, prototype)
- ✅ Safe JSON parsing - Proper error handling for invalid JSON
- 🛡️ Array bounds checking - Prevents out-of-bounds access
- 🔍 Input validation - Validates path segments before processing
Check your security status:
``bash`
npm run migration:status
See SECURITY.md for detailed security information and best practices.
Check migration compatibility when upgrading:
`bash``
npm run migration:check 0.0.4
This will show:
- Breaking changes between versions
- Security improvements
- Migration steps required
released under the MIT license.
Semantic Versioning for versioning.
- Julien Appéré <@empreintes> -
Github | Twitter
- This is a side project of a side project of a side project (for real)
- Use in production only if you know what you do.
- Extend Map Object for personal choice.