minijson 0.5.1

Minify JSON files


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

minijson

Minify JSON files blazing fast! Supports Comments. Written in D.

360 times faster than jsonminify!

CI

Installation

  • Nodejs
npm install @aminya/minijson
  • CLI Binaries

You can also download the binaries for the CLI from the release page:

https://github.com/aminya/minijson/releases/tag/v0.5.1

  • Dub
dub build --config=library --build=release-nobounds --compiler=ldc2
# or
dub build --config=executable --build=release-nobounds --compiler=ldc2

CLI Usage

❯ minijson --help

minijson: minify json files with support for comments
    minijson --file file1.json --file file2.json
    minijson --file file1_with_comment.json --file file2_with_comment.json --comment

    minijson --string '{"some_json": "string_here"}'
    minijson --string '{"some_json": "string_here"} //comment' --comment

    More information at https://github.com/aminya/minijson

      --file an array of files to minify
    --string a json string to minify
   --comment a flag to support comments in json
-h    --help This help information.

Node API

import { minifyFiles, minifyString } from "minijson"

// minify the files in-place and in parallel
await minifyFiles(["file1.json", "file2.json"])

// supports comments by passing true as the second argument
await minifyFiles(["file1_with_comment.json", "file2_with_comment.json"], true)

// minify the given string
const minifiedString = minifyString(`{"some_json": "here"}`)

// supports comments by passing true as the second argument
const minifiedString2 = minifyString(`{"some_json": "here"}//comment`, true)

Note: in the Nodejs API, prefer minifyFiles over other functions, as it minifies the files in parallel with the least amount of resources.

D API

import minijson: minifyString, minifyFiles;

// minify the given string
const minifiedString = minifyString(`{"some_json": "here"}`);

// supports comments by passing true as the second argument
const minifiedString2 = minifyString(`{"some_json": "here"}//comment`, true);

// minify the files in-place and in parallel
minifyFiles(["file1.json", "file2.json"]);

// supports comments by passing true as the second argument
minifyFiles(["file1.json", "file2.json"], true);

Benchmarks

On AMD Ryzen 7 4800H:

❯ node .\benchmark\native-benchmark.mjs
0.163 seconds

❯ node .\benchmark\js-benchmark.mjs
58.818 seconds

Contributing

pnpm install
pnpm run build.node

License

The project is licensed under MIT. It was inspired by fkei/JSON.minify.

Authors:
  • Amin Yahyaabadi
Dependencies:
automem
Versions:
0.6.2 2021-Dec-30
0.6.1 2021-Dec-30
0.6.0 2021-Jul-11
0.5.1 2021-Jul-10
0.5.0 2021-Jul-07
Show all 17 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 24 downloads total

Score:
0.0
Short URL:
minijson.dub.pm