
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
@dormammuuuuu/json-helper
Advanced tools
A library that provides utility functions for traversing and manipulating JSON data.
JSONHelper is a utility for efficiently traversing and manipulating nested JSON objects. It helps users search for nodes, retrieve parents, find siblings, and more, in hierarchical or tree-structured data. This is the modernization of dabeng/json-digger
.
npm install json-helper
import { JSONHelper } from 'json-helper';
const datasource = {
pk: '1',
name: 'Lao Lao',
title: 'general manager',
inferiors: [/* Nested children */]
};
const helper = JSONHelper({
datasource,
idProp: 'pk',
childrenProp: 'inferiors'
});
const node = helper.findNodeById('1'); // Find node by ID
findNodeById(id)
Find a node by its ID.
const node = helper.findNodeById('1');
findOneNode(conditions)
Find the first node that matches a set of conditions.
const node = helper.findOneNode({ name: 'Xiang Xiang' });
findNodes(conditions)
Find all nodes matching the conditions.
const nodes = helper.findNodes({ title: /engineer/i });
findParent(id)
Find the parent of a node by its ID.
const parent = helper.findParent('2');
findSiblings(id)
Find the siblings of a node by its ID.
const siblings = helper.findSiblings('2');
findAncestors(id)
Get the ancestors of a node.
const ancestors = helper.findAncestors('6');
addChildren(id, data)
Add child nodes to a given node.
helper.addChildren('2', { pk: '11', name: 'New Child' });
addSiblings(id, data)
Add sibling nodes to a given node.
helper.addSiblings('2', { pk: '11', name: 'New Sibling' });
addRoot(data)
Replace the root node with new data.
helper.addRoot({ pk: '11', name: 'New Root' });
updateNode(data)
Update the properties of a node.
helper.updateNode({ pk: '1', name: 'Updated Name' });
updateNodes(ids, data)
Update multiple nodes' properties.
helper.updateNodes(['1', '2'], { title: 'New Title' });
removeNode(id)
Remove a node by its ID.
helper.removeNode('2');
removeNodes(param)
Remove multiple nodes based on IDs or conditions.
helper.removeNodes(['2', '3']);
Run tests using the following command:
npm run test
FAQs
A library that provides utility functions for traversing and manipulating JSON data.
The npm package @dormammuuuuu/json-helper receives a total of 16 weekly downloads. As such, @dormammuuuuu/json-helper popularity was classified as not popular.
We found that @dormammuuuuu/json-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.