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

json-maker

v1.2.4

Published

Allows for easy creation of JSON files

Downloads

19

Readme

json-maker

About

json-maker is an easy to use JSON making tool, with the ability to write JSON files and use the raw JSON object as a variable.

Installation

NPM 5.0.0 or above:

npm install json-maker

NPM 4.6.1 or below:

npm install --save json-maker

Constructor

load

Optional: True

Returns: Nothing

options

  • path : File to load on construction

Loads a JSON file on construction into the native JSON storage.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker('./kek9.json');

setTimeout(() => {
    console.log(JSON.stringify(jsonMaker.json));
}, 1000);

API

json

Returns: JSON Object

Returns the raw JSON Object that was created using addField()

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

console.log(JSON.stringify(jsonMaker.json));

addField(title, data)

Returns: Module

options

  • title : Title of JSON entry
  • data : Data to be associated with JSON title

Adds a field to the JSON object with the specified title and data values.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.addField('kek9', 'lul5');

console.log(JSON.stringify(jsonMaker.json));

removeField(title)

Returns: Module

options

  • title : Title of JSON entry

Allows you to delete a field based on the key title.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.removeField('kek9');

console.log(JSON.stringify(jsonMaker.json));

write(file-path)

Returns: Promise

options

  • file-path : Path and file to write to. Has no extension by default.

Writes the JSON object in the package to a the specified file.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.write('./kek.json').then(() => console.log('Wrote to file')).catch(err => console.error(err));

load(file-path)

Returns: Promise

options

  • file-path : Path and file to load from. Has no extension by default.

Loads the JSON object from the file specified.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.load('./test.json').then(()=>{
    console.log(JSON.stringify(jsonMaker.json));
});

exists(title)

Returns: Boolean

options

  • title : Title of JSON entry

Returns a boolean depending on if the entry exists or not.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

console.log(jsonMaker.exists('kek9'));

clear()

Returns: null

Clears the JSON object in the package.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.clear();

console.log(JSON.stringify(jsonMaker.json));

get(title)

Returns: null or Key Value

options

  • title : Key name of the JSON field

Allows you to get the value of a key from the JSON object.

const _jsonMaker = require('json-maker');
const jsonMaker = new _jsonMaker();

jsonMaker.addField('title-here', 'value-here');

console.log(jsonMaker.get('title-here'));

To-Do

Allow for extra JSON objects

'Nuff said

Make option to automatically stringify

Since this package will most likely become a class, it would be a part of the constructor.

Make option for multiple fields with same key value

Since this package will most likely become a class, it would be a part of the constructor.