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 🙏

© 2026 – Pkg Stats / Ryan Hefner

select-json-by-json

v1.7.1

Published

Select a nested JSON structure using a JSON projection spec.

Readme

select-json-by-json

A high-performance standalone JSON projection engine for Node.js and modern browsers. Engine v6.0 · Package v1.6.1

GitHub Pages npm License: MIT


🔗 Quick Links


How It Works

selectJson(source, spec) takes two arguments:

| Argument | Role | |---|---| | source (1st) | The input JSON — an object or array to project from. Never mutated. | | spec (2nd) | The projection spec — a JSON object declaring which fields to keep. |

The result is always a new object/array with only the fields declared in the spec. The original source is untouched.

const result = selectJson(source, spec);
// source is never modified — result is a fresh projection

Spec Rules

| Spec value | Meaning | |---|---| | true | Keep this field from source as-is | | { ... } | Descend into nested object/array with sub-spec | | (absent) | Field is excluded from result |


📦 Installation & Usage

1. NPX — Copy Engine to Your Project

Copies the highest engine version (v6) directly into your project as plain JS files, zero dependencies:

# Copies v6 engine to ./select-json-by-json/
npx select-json-by-json

# Custom destination:
npx select-json-by-json ./src/lib/engine

# Target a specific version:
npx select-json-by-json ./lib/engine --version-target=v6
npx select-json-by-json ./lib/engine --version-target=v5

# Show all options:
npx select-json-by-json --help

After copying, import directly:

import { selectJson } from "./select-json-by-json/index.js";

const result = selectJson(source, { DATE: true, VOUCHERNUMBER: true });

2. NPM Package

npm install select-json-by-json
// Latest engine (v6)
import { selectJson } from "select-json-by-json";

// Pin a specific engine version:
import { selectJson } from "select-json-by-json/v6";
import { selectJson } from "select-json-by-json/v5";

const result = selectJson(sales, {
    DATE: true,
    VOUCHERNUMBER: true,
    "ALLINVENTORYENTRIES.LIST": {
        STOCKITEMNAME: true,
        RATE: true
    }
});

3. CDN (ES Module — Browser)

<script type="module">
    import { selectJson } from "https://keshavsoft.github.io/select-json-by-json/docs/dist/min.js";

    const result = selectJson(sourceData, {
        DATE: true,
        VOUCHERNUMBER: true
    });

    console.log(result);
</script>

Also registered globally as globalThis.ks["select-json-by-json"] and globalThis.ks.selectJson.

🌐 Try it live: Interactive Playground


🧪 Testing

# Run the Node.js native test suite
npm test

# Quick manual tests
node ./test/v2/index.js
node ./test/v1/index.js

🛠️ Build Commands

| Command | Description | |---|---| | npm run build | Bundles highest src/vN with Vite → docs/dist/vN/min.js and docs/dist/min.js | | npm test | Runs Node.js native test suite | | npm start | Runs the demo in save.js |


📁 Project Structure

src/
  index.js              ← re-exports from src/v6 (latest)
  v5/                   ← previous engine version
  v6/                   ← current engine (v6.0)
    02-engine.js
    03-inspect.js
    04-project.js
    05-objectProjector.js
    06-arrayProjector.js
    07-selectors.js
    registerGlobal.js
    meta.js
    index.js

bin/
  cli.js                ← npx CLI — copies highest src/vN to destination

test/
  v1/                   ← manual test with source.json + spec.json
  v2/                   ← manual test with updated spec

docs/
  index.html            ← Live playground (GitHub Pages)
  dist/
    min.js              ← latest CDN bundle (v6)
    v6/min.js           ← versioned CDN bundle