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

json-mapping-js

v1.0.0

Published

A javascript library to map JSON objects.

Downloads

4

Readme

json-mapper

A useful helper to map data from a json object on Node.jS environments.

Table of contents

Installation

Node.js

  1. Install module:

    npm install json-mapping --save

  2. Then try it.

Usage

import jsonMapping from 'json-mapping';

const jsonMapper = jsonMapping(someJsonInput); // input the json data
const object = jsonMapper({ type: 'object' }); // convert the inputed json data to javascript literal object
const xml = jsonMapper({ type: 'xml', mapping, prettify: true }); // convert the inputed json data to xml based on a mapping array

Output types

Object

Runs the json mapper function passing the type 'object' as an argument to map your json data.

import jsonMapping from 'json-mapping';

const jsonMapper = jsonMapping(someJsonInput);
const object = jsonMapper({ type: 'object' });

XML

Runs the json mapper function passing the type 'xml' and a mapping array as arguments to map your json data.

import jsonMapping from 'json-mapping';

const jsonMapper = jsonMapping(someJsonInput);
const xml = jsonMapper({ type: 'xml', mapping, prettify: true });

Mapping

| argument | type | required | description |--|--|--|--| | target | string | true | XML target tag you want to fill | origin | string | false | JSON path where you want to get data from | static_value | any | false | A static value to the XML target tag | convert_function | string | false | Function to convert the origin data

Mapping samples

The '!!' characters assumes the target will be setted only if value isn't undefined.

{
  "origin": "!!extension_attributes.bold_order_comment",
  "target": "CommentLine.CustomerPoLine"
}

The 'x' character assumes the origin 'items' will be a iterable array.

{
  "origin": "items.x.name",
  "target": "Customers.CustomerName"
}

The convert_function property will be executed as a javascript function receiving the value as a parameter.

{
  "origin": "customer.born_date",
  "target": "Header.CustomerAge",
  "convert_function": "return new Date().getFullYear() - new Date(value).getFullYear()"
}