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

@need-some/json

v0.1.3

Published

json binding

Readme

need-some-json.js

Build Status License: MIT npm version need-some/json Dependencies

need-some is a collection of small yet useful functions. The json package provides typed json binding

Installation

Simply install as dependency

npm install @need-some/json --save

Usage

Use JsonConverter to translate json strings to typed objects(using the concrete classes) and back. The Json annotations cannot type check its annotated members, so it must be defined carefully.

Create a converter

class MyClass {
	id: number
}

const converter = new JsonConverter(MyClass);

const json = converter.marshal(obj);

const obj2 = converter.unmarshal(json);

JsonMarshaller

Instance to convert objects to json strings.

JsonMarshaller

Instance to convert json strings to objects.

JsonConverter

Bot Marshaller and Unmarshaller

Binding annotations

Force Classname

If running minified code, the marshaller is not able to find the class name and adds members to random class descriptors. To mitigate or allow multiple classes to be named identical, add a static member to the class:

static __JSON__CLASSNAME = 'SomeReallyUniqueName';
@JsonElement

Simple annotation denoting an element to be a json element. Optional, if no renaming of the member is done. and other json annotations are present.

@JsonElement()
id: number;

@JsonElement('nameInJson')
nameInObj: string;
@JsonNull

Define member to be nullable. The json representation is the "null" json value

@JsonNull()
nember: string | null;
@JsonOptional

Define member to be optional. The json will not contain the key if the object representation is undefined.

@JsonOptional()
nember?: string;
@JsonChild

Define class of member to delegate to new JsonConverter for the given class.

@JsonChild(ChildClass)
child: ChildClass;
@JsonEnum

Define enum type of member. The Json representation is the string key.

@JsonEnum(Enum)
nember: Enum;
@JsonDiscriminator

Mark member to be the discriminator member of a super class. Should be used on string members. Note that the type can be private to the parent class and will be set when performing a conversion

@JsonDiscriminator()
private type: string
@JsonDiscriminatorValue

Set value to identify subclass in the discriminator member

@JsonDiscriminatorValue('CAR')
class Car extends Vehicle
@JsonTypes

List all subclasses of the given class. Given as function, so declaration before the actual child classes is possible

@JsonTypes(()=>[Car, Motorbike])
class Vehicle
@JsonTransform

Declare a converter to be used when processing the member. A converter has a marshal and an unmarshal function. The parameter may be a converter instance, converter constructor or a converter factory or even a converter factory constructor

@JsonTransform(DateConverter)
date:Date;