npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jsonhero/parser

v1.0.9

Published

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.

Downloads

11

Readme

JSON Hero Parser

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.

How to install

npm install @jsonhero/parser

Getting started

Importing

You can require

const { parse } = require('@jsonhero/parser');

Or if you're using TypeScript:

import { parse } from '@jsonhero/parser';

How to parse

Sample object

Given the following JSON variable called employees

let employees = {
  people: [
    {
      name: 'Matt',
      age: 36,
    },
    {
      name: 'James',
      age: 39,
    },
  ],
  count: 2,
};

Parsing

You parse a JSON object like this:

let structure = parse(employees);

Values and Structure

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 |

The output

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
      }
    }
  }
}