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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mr-json2json

v1.0.3

Published

converts json to json using node, just construct your own template, keywords and hint and get your json. Use it to prepare and clean your data

Downloads

8

Readme

MR-JSON2JSON

image This module converts json to json using node, just construct your own template, keywords and hint and get your json. Use it to prepare and clean your data

Installation

npm install --save mr-json2json

Requiring:

var mrjson2json = require('mr-json2json');

Usage

mrjson2json(template, data);

Sample data

data = {
    "ID,N,10,0": 131,
    "ADDR_INFO,C,254": "",
    "TITLE,C,250": "Textile Museum of Canada",
    "CATEGORY,C,150": "Museum",
    "PHONE,C,50": "416-366-3561",
    "EMAIL,C,100": "",
    "WEBSITE,C,254": "www.textilemuseum.ca",
    "ADDRESS,C,131": "55 Centre Ave",
    "POSTAL_CD,C,7": "M5G 2H5",
    "X,N,11,4": 313927.085,
    "Y,N,11,4": 4834743.652,
    "LONGITUDE,N,14,11": -79.3866557106,
    "LATITUDE,N,14,11": 43.6545873402,
    "OBJECTID,N,20,0": 131,
    "SRC_ADDRSS,C,100": "55 Centre Avenue",
    "LEVEL,N,5,0": 3,
    "DESCRIPTIO,C,254": "With more than 13,000 objects from more than 200 countries and regions, the Textile Museum of Canada celebrates cultural diversity through traditional fabrics, garments, carpets and related artifacts such as beadwork and basketry."
}

Template

It is recommended to put your template in template.js . You will then need to require template.js using var template = require('./template.js');

You might need to use these libraries in your template.js

var moment = require('moment');
var validator = require('validator');

This is how your template.js looks like.

function template() {
  return {
    "name": {
      "keywords":[ "name", "title", "summary", "event name", "landmark", "location name", "activity name"],
      "stopKeywprds": ["street", "contact", "person", "parent", "file", "partner"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "description": {
      "keywords":["content", "description"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "summary": {
      "keywords":["summary"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "lat": {
      "keywords": ["latitude" , "lat", "y"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isFloat(input.toString() , { min: -90, max: 90 })
      }
    },
    "long": {
      "keywords": ["longitude", "lng", "x"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isFloat(input.toString() , { min: -180, max: 180 })
      }
    },
    "postalCode": {
      "keywords": ["postal cd", "postal code", "zip code"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "address": {
      "keywords": ["location", "locations", "address", "street no", "street number", "street name", "street type", "city", "postal cd", "postal code", "zip code", "country"],
      "stopKeywprds": ["id", "type"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "streetNumber": {
      "keywords": ["street no", "street number"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "streetName": {
      "keywords": ["street name", "street type"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "city": {
      "keywords": ["city"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "country": {
      "keywords": ["country"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "state": {
      "keywords": ["state"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "startDate": {
      "keywords": ["start", "from"],
      "stopKeywprds": ["end", "first", "last", "to", "time", "range"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return moment(input)._isValid;
      }
    },
    "endDate": {
      "keywords": ["end", "to"],
      "stopKeywprds": ["start", "first", "last", "from", "time", "range"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return moment(input)._isValid;
      }
    },
    "startTime": {
      "keywords": ["time", "start", "from"],
      "stopKeywprds": ["end", "first", "last", "to", "range"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return moment(input)._isValid;
      }
    },
    "endTime": {
      "keywords": ["time", "end", "to"],
      "stopKeywprds": ["start", "first", "last", "from", "range"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return moment(input)._isValid;
      }
    },
    "tags": {
      "keywords": ["tags", "tag"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "phone": {
      "keywords": ["phone"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isMobilePhone(input, 'any');
      }
    },
    "website": {
      "keywords": ["website"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isURL(input);
      }
    },
    "email": {
      "keywords": ["email"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isEmail(input);
      }
    },
    "parking": {
      "keywords": ["parking"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "price": {
      "keywords": ["price", "cost", "fee"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "category": {
      "keywords": ["category", "categories", "location type", "tags", "tag"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "image": {
      "keywords": ["image", "images", "img", "pictures"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return validator.isURL(input);
      }
    },
    "type": {
      "keywords": ["type", "location type"],
      "stopKeywprds": ["street", "location"],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "isEvent": {
      "keywords": [],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "accessibility": {
      "keywords": [],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    },
    "reservationsRequired": {
      "keywords": ["website"],
      "stopKeywprds": [],
      keyHint: function(input){
        return true;
      },
      valueHint: function(input){
        return true;
      }
    }
  }
}