|
1 | 1 | # littlejson |
2 | 2 |
|
3 | | -LittleJSON is a lightweigh CLI to compress and decompress JSON files. |
| 3 | +**A lightweight CLI for compressing and decompressing JSON files.** |
| 4 | + |
| 5 | +`littlejson` utilizes MessagePack for efficient binary serialization of JSON data, offering potentially significant size reductions for your JSON files. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- **Compress JSON to LJSON:** Reduces file size using MessagePack binary encoding. |
| 10 | +- **Decompress LJSON to JSON:** Restores compressed LJSON files back to readable JSON format. |
| 11 | +- **Simple CLI:** Easy-to-use command-line interface with clear instructions. |
| 12 | +- **File size analysis:** Provides details about the original size, compressed/decompressed size, and the percentage of change. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +**Global Installation:** |
| 17 | +If you perform a global installation, you can use the `littlejson` command directly instead of running it through `npx`. |
| 18 | + |
| 19 | +```bash |
| 20 | +npm install -g littlejson |
| 21 | +``` |
4 | 22 |
|
5 | 23 | ## Usage |
6 | 24 |
|
| 25 | +### Compressing JSON Files |
| 26 | + |
| 27 | +To compress a JSON file into a `.ljson` file: |
| 28 | + |
| 29 | +```bash |
| 30 | +npx littlejson compress <input-file.json> [output-file.ljson] |
| 31 | +``` |
| 32 | + |
| 33 | +- `<input-file.json>`: The path to your JSON input file. |
| 34 | +- `[output-file.ljson]`: (Optional) The desired path for the compressed output file. If not provided, the output file will be named with the same base name as the input but with the `.ljson` extension, saved in the current working directory. |
| 35 | + |
| 36 | +**Example:** |
| 37 | + |
7 | 38 | ```bash |
8 | | -npx littlejson compress <input-file> <output-file> |
9 | | -npx littlejson decompress <input-file> <output-file> |
| 39 | +npx littlejson compress data.json compressed.ljson |
| 40 | +# or |
| 41 | +npx littlejson compress data.json |
10 | 42 | ``` |
11 | 43 |
|
| 44 | +### Decompressing LJSON Files |
| 45 | + |
| 46 | +To decompress a `.ljson` file back into a `.json` file: |
| 47 | + |
| 48 | +```bash |
| 49 | +npx littlejson decompress <input-file.ljson> [output-file.json] |
| 50 | +``` |
| 51 | + |
| 52 | +- `<input-file.ljson>`: The path to your LJSON input file. |
| 53 | +- `[output-file.json]`: (Optional) The desired path for the decompressed output file. If not provided, the output file will be named with the same base name as the input but with the `.json` extension, saved in the current working directory. |
| 54 | + |
| 55 | +**Example:** |
| 56 | + |
| 57 | +```bash |
| 58 | +npx littlejson decompress compressed.ljson decompressed.json |
| 59 | +# or |
| 60 | +npx littlejson decompress compressed.ljson |
| 61 | +``` |
| 62 | + |
| 63 | +## Output |
| 64 | + |
| 65 | +The CLI provides useful details upon completion: |
| 66 | + |
| 67 | +- Success/error messages |
| 68 | +- Original file size |
| 69 | +- Compressed/Decompressed file size |
| 70 | +- Compression/Size change percentage |
| 71 | + |
12 | 72 | ## License |
13 | 73 |
|
14 | | -MIT |
| 74 | +[MIT](LICENSE) |
| 75 | + |
| 76 | +## Contributing |
| 77 | + |
| 78 | +Contributions are welcome! Feel free to submit a pull request or open an issue. |
0 commit comments