
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@jsonhero/parser
Advanced tools
A parser that walks through a JSON file and for each value determines the path to it, the type and paths to any children. It also builds a model of the structure of the data.
A parser that walks through a JSON file and for each value determines the path to it, the type and paths to any children. It also builds a model of the structure of the data.
npm install @jsonhero/parser
You can require
const { parse } = require('@jsonhero/parser');
Or if you're using TypeScript:
import { parse } from '@jsonhero/parser';
Given the following JSON variable called employees
let employees = {
people: [
{
name: 'Matt',
age: 36,
},
{
name: 'James',
age: 39,
},
],
count: 2,
};
You parse a JSON object like this:
let structure = parse(employees);
There are two top-level objects called values and structure.
Values has details for every single value from the parsed object. Structure groups together details to represent the actual data structure.
They have the following properties for each element:
| Key name | Description |
|---|---|
path | A JSONHeroPath as a string that points to this value |
name | The originally formatted name |
displayName | A nicely formatted name |
value | The value itself |
type | A Type from JSON Hero's infer types package |
children | Null or an array of string paths to child values |
This produces an object that looks like this:
{
"values": {
"rootPath": "$",
"values": {
"$": {
"path": "$",
"name": "Root",
"displayName": "Root",
"value": {
"people": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
],
"count": 2
},
"type": {
"name": "object",
"value": {
"people": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
],
"count": 2
}
},
"children": ["$.people", "$.count"]
},
"$.people": {
"path": "$.people",
"name": "people",
"displayName": "People",
"value": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
],
"type": {
"name": "array",
"value": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
]
},
"children": ["$.people.0", "$.people.1"]
},
"$.people.0": {
"path": "$.people.0",
"name": "people 0",
"displayName": "People 0",
"value": { "name": "Matt", "age": 36 },
"type": { "name": "object", "value": { "name": "Matt", "age": 36 } },
"children": ["$.people.0.name", "$.people.0.age"]
},
"$.people.0.name": {
"path": "$.people.0.name",
"name": "name",
"displayName": "Name",
"value": "Matt",
"type": { "name": "string", "value": "Matt" },
"children": null
},
"$.people.0.age": {
"path": "$.people.0.age",
"name": "age",
"displayName": "Age",
"value": 36,
"type": { "name": "int", "value": 36 },
"children": null
},
"$.people.1": {
"path": "$.people.1",
"name": "people 1",
"displayName": "People 1",
"value": { "name": "James", "age": 39 },
"type": { "name": "object", "value": { "name": "James", "age": 39 } },
"children": ["$.people.1.name", "$.people.1.age"]
},
"$.people.1.name": {
"path": "$.people.1.name",
"name": "name",
"displayName": "Name",
"value": "James",
"type": { "name": "string", "value": "James" },
"children": null
},
"$.people.1.age": {
"path": "$.people.1.age",
"name": "age",
"displayName": "Age",
"value": 39,
"type": { "name": "int", "value": 39 },
"children": null
},
"$.count": {
"path": "$.count",
"name": "count",
"displayName": "Count",
"value": 2,
"type": { "name": "int", "value": 2 },
"children": null
}
}
},
"structure": {
"rootPath": "$",
"values": {
"$": {
"path": "$",
"name": "Root",
"displayName": "Root",
"type": {
"name": "object",
"value": {
"people": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
],
"count": 2
}
},
"children": ["$.people", "$.count"]
},
"$.people": {
"path": "$.people",
"name": "people",
"displayName": "People",
"type": {
"name": "array",
"value": [
{ "name": "Matt", "age": 36 },
{ "name": "James", "age": 39 }
]
},
"children": ["$.people.*"]
},
"$.people.*": {
"path": "$.people.*",
"name": "people",
"displayName": "People",
"type": { "name": "object", "value": { "name": "Matt", "age": 36 } },
"children": ["$.people.*.name", "$.people.*.age"]
},
"$.people.*.name": {
"path": "$.people.*.name",
"name": "name",
"displayName": "Name",
"type": { "name": "string", "value": "Matt" },
"children": null
},
"$.people.*.age": {
"path": "$.people.*.age",
"name": "age",
"displayName": "Age",
"type": { "name": "int", "value": 36 },
"children": null
},
"$.count": {
"path": "$.count",
"name": "count",
"displayName": "Count",
"type": { "name": "int", "value": 2 },
"children": null
}
}
}
}
FAQs
A parser that walks through a JSON file and for each value determines the path to it, the type and paths to any children. It also builds a model of the structure of the data.
The npm package @jsonhero/parser receives a total of 1 weekly downloads. As such, @jsonhero/parser popularity was classified as not popular.
We found that @jsonhero/parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

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