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

@light0x00/jsonx

v0.1.1

Published

A JSON extension for Javascript.

Readme

JSONX

A JSON Extension Implementation for Javascript.

License: MIT

中文文档

Features

Customizable converter

Whenever matching data is encountered, the specified converter-function is called, and the return value determines the converting result of the matching data.

Two types of converters are supported:

  • class conveter ,Match by Class (xx.constructor)

    let jsonx = new JSONXBuilder()
    	.addClassConverter(Date, (d: Date) => d.getFullYear()+"-"+d.getMonth())
    	.build()
    jsonx.stringify({date:new Date()}  //output: "{"date":"2020-2"}"
  • property conveter, Match by property name

    let jsonx = new JSONXBuilder()
    	.addPropertyConverter("map", (obj: Map<any, any>) => Array.from(obj.entries()))
    	.build()
    let r = jsonx.stringify( { map: new Map([["key1", "val1"]]) } )
    console.log(r)  //output: {"map":[["key1","val1"]]}

Loose analysis rules

The comment、unclosed comma are supported

let r = jsonx.parse(`{
	/* Some comments */
	"target": "ESNext", //Some comments
	"lib": [
		"ESNext", /* multiline comment is supported */
		null  //null is supported
	], //unclosed comma is supported
}`)
console.log(r)  //output: {"target":"ESNext","lib": ["ESNext",null]}

Detailed error reports

When an error occurs, report the expected content, and the error location

let r = jsonx.parse(`{
	"target":"ESNext",
	:
 }`)

//Error: The expected input is "}" or "STRING" ,but got ":" at (3,1) ~ (3,2)

The location format where error occurred: (start row,start column) ~ (end row,end column)

Circular references detection

When a circular reference detected, report the reference chain

class Member {
	name: string;
	lover?: Member;
	constructor(name: string) {
		this.name = name
	}
	toString() { return this.name }
}

let jack = new Member("jack")
let rose = new Member("rose")
let alice = new Member("alice")
let bob = new Member("bob")
jack.lover = rose
rose.lover = alice
alice.lover = bob
bob.lover = jack

jsonx.stringify(jack)
// Error: circular references detected: jack->rose->alice->bob->jack

Install

npm

npm install @light0x00/jsonx

browser

<script src="path/to/jsonx.min.js"></script>
<script>
	let {default: JSONX , JSONXBuilder } = JSONX_LIB 
</script>

Usage

Support both ESModule and CommonJS, use ESModule as example below.

Basic usage

import JSONX from "@light0x00/jsonx"

JSONX.parse(`{"foo":"bar"}`)
JSONX.parse(`["foo","bar"]`)

JSONX.stringify({foo:"bar"})
JSONX.stringify(["foo","bar"])

//By default `Date` type is converted to : `dateObj.toISOString()`
let r  =JSONX.stringify([new Date()])
console.log(r)  //output: ["2020-03-04T06:24:02.927Z"]

Customized usage

import { JSONXBuilder } from "@light0x00/jsonx"

//Build a `JSONX` object according your demand
let jsonx = new JSONXBuilder()
	.addClassConverter(Date, (obj: Date) => obj.toLocaleDateString())
	.addPropertyConverter("relationships", (obj: Map<string, string>) => Array.from(obj.entries()))
	.build()

//Use it
let d = {
	name: "foo",
	date: new Date(),
	members: [
		{ name: "alice" },
		{ name: "bob" },
	],
	relationships: new Map<string, string>([["alice", "bob"]])
}
let r = jsonx.stringify(d)

//Result
should(r).eql(`{"name":"foo","date":"${d.date.toLocaleDateString()}","members":[{"name":"alice"},{"name":"bob"}],"relationships":[["alice","bob"]]}`)