<commit_before># JSON-Slim

[![Build Status](https://travis-ci.org/arminrosu/json-slim.svg?branch=master)](https://travis-ci.org/arminrosu/json-slim)
[![Dependencies](https://david-dm.org/arminrosu/json-slim.svg)](https://david-dm.org/arminrosu/json-slim)

Minify JSON better than JSON.stringify().

It achieves this by converting Numbers, number Strings and Booleans to a shorter form. You should be aware of this in your application, type checks might fail.

## Installation

```sh
npm i json-slim
```

## Example

```js
var slim = require('json-slim');

var json = slim({
	true:                  true,
	false:                 false,
	number:                123000,
	numberString:          '123000',
	decimalFraction:       0.00123,
	decimalFractionString: '0.00123',
	exponent:              1.23E+5,
	exponentString:        '1.23e+5',
	customField:           '<NAME>'
}, {
	// JSON-slim reports only to you
	report:    true,
	// You can add your own minifiers too
	minifiers: [
		{
			// RegExp Pattern
			pattern: '"<NAME>"',
			replace: function(string) {
				return '"I am <NAME>"';
			}
		}
	]
});

console.log(json);
```

Output:

```bash
JSON-Slim: 90% of original.
```

```bash
{"true":1,"false":0,"number":123e3,"numberString":123e3,"decimalFraction":123e-5,"decimalFractionString":123e-5,"exponent":123e3,"exponentString":123e3,"customField":"I am L<NAME>ort"}
```

## Even less?

Check out [json-lean](https://github.com/arminrosu/json-lean) if your JSON requests have the same object structure.
<commit_msg>update readme with unicode conversion<commit_after># JSON-Slim

[![Build Status](https://travis-ci.org/arminrosu/json-slim.svg?branch=master)](https://travis-ci.org/arminrosu/json-slim)
[![Dependencies](https://david-dm.org/arminrosu/json-slim.svg)](https://david-dm.org/arminrosu/json-slim)

Minify JSON better than `JSON.stringify()`.

It achieves this by converting Numbers, number Strings and Booleans to a shorter form. Unicode characters are converted automatically by _JSON.stringify()_, which is used internally.

You should be aware of the potential type conversion _json-slim_ performs, as type checks in your application might fail.

## Installation

```sh
npm i json-slim
```

## Example

```js
var slim = require('json-slim');

var json = slim({
	boolean:     true,
	number:      '123000',
	unicode:     '\u03A9',
	customField: '<NAME>'
}, {
	// JSON-slim reports only to you
	report:    true,
	// You can add your own minifiers too
	minifiers: [
		{
			// RegExp Pattern
			pattern: '"<NAME>"',
			replace: function(string) {
				return '"I am L<NAME>"';
			}
		}
	]
});

console.log(json);
```

Output:

```bash
JSON-Slim: 93% of original.
```

```bash
{"boolean":1,"number":123e3,"unicode":"Ω","customField":"I am Lord Voldemort"}
```

## Even less?

Check out [json-lean](https://github.com/arminrosu/json-lean) if your JSON requests have the same object structure.

{'fraction_non_alphanumeric': 0.15943526170798897, 'fraction_numerical': 0.026170798898071626, 'mean_word_length': 3.7235772357723578, 'pattern_counts': {'":': 13, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '550176', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1004, 'n_words': 248}