# lighter-json

> A lightweight JSON utility library.

Latest version **2.0.0** (published 2017-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install lighter-json
pnpm add lighter-json
yarn add lighter-json
bun add lighter-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-02-23 |
| First published | 2015-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.28 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sam Eubank |
| Maintainers | zerious |
| Keywords | json, circular, safe, stringify, scriptify, evaluate, javascript, object, notation, parse, eval, stream, object, mode, readableStream, writableStream, douglas, crockford, utility, lighter, fast, lightweight, minimal, benchmark, speed, ops, readable, writable |

## Links

- npm: https://www.npmjs.com/package/lighter-json
- Repository: https://github.com/lighterio/lighter-json
- Issues: https://github.com/lighterio/lighter-json/issues
- npm.io page: https://npm.io/package/lighter-json

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-02-23
- 1.0.2 — 2016-07-20
- 1.0.1 — 2015-12-15
- 1.0.0 — 2015-12-15

## README

# lighter-json
[![Chat](https://badges.gitter.im/chat.svg)](//gitter.im/lighterio/public)
[![Version](https://img.shields.io/npm/v/lighter-json.svg)](//www.npmjs.com/package/lighter-json)
[![Downloads](https://img.shields.io/npm/dm/lighter-json.svg)](//www.npmjs.com/package/lighter-json)
[![Build](https://img.shields.io/travis/lighterio/lighter-json.svg)](//travis-ci.org/lighterio/lighter-json)
[![Coverage](https://img.shields.io/codecov/c/github/lighterio/lighter-json/master.svg)](//codecov.io/gh/lighterio/lighter-json)
[![Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](//www.npmjs.com/package/standard)

The `lighter-json` module is a lightweight JavaScript Object Notation utility.

## Quick Start
From your project directory, install and save as a dependency:
```bash
npm install --save lighter-json
```

Then use `lighter-json` in place of the global `JSON` object for circular
reference safety and more.

```
var JSON = require('lighter-json')

// Create a circular reference, if you like.
var object = {}
object.reference = object

// It's OK, you're safe.
var json = JSON.stringify(object)
console.log(json)

//> {"reference":"[Circular 1]"}
```

## API
The `lighter-json` package exports an object with several methods for dealing
with JSON and non-strict JSON. It also populates same-name methods onto the
global JSON object, apart from its `stringify` method, which is populated as
`JSON.safeStringify`.

### lighterJson.stringify(value[, replacer[, space]])
Perform a JSON stringify operation on a value, using automatic cycle detection
if a replacer function is not provided.

### lighterJson.parse(json)
Parse a JSON string (using the builtin `JSON.parse`).

### lighterJson.scriptify(value)
Represent a value as non-strict JSON, complete with JS code for
re-constructing Date, Error, Function and RegExp values.

### lighterJson.evaluate(js)
Evaluate and return a value from a JavaScript string representation. This
supports non-strict JSON, so a value (or a deep property) can be a Date, a
Function, an Error or a RegExp.

### lighterJson.reader(readableStream)
Listen to a readable stream that's not in object mode, and interpret its
lines as JavaScript values (using `lighterJson.evaluate`).

### lighterJson.unreader(readableStream)
Stop listening for values on a readable stream.

### lighterJson.writer(writableStream)
Replace the stream's write method with one that accepts objects and writes non-strict JSON.

### lighterJson.unwriter(writableStream)
Puts a writable stream's write method back.

### lighterJson.colorize(value)
Evaluate and return a value from a JavaScript string representation. This
supports non-strict JSON, so a value (or a deep property) can be a Date, a
Function, an Error or a RegExp.

## More on lighter-json...
* [Contributing](//github.com/lighterio/lighter-json/blob/master/CONTRIBUTING.md)
* [License (ISC)](//github.com/lighterio/lighter-json/blob/master/LICENSE.md)
* [Change Log](//github.com/lighterio/lighter-json/blob/master/CHANGELOG.md)
* [Roadmap](//github.com/lighterio/lighter-json/blob/master/ROADMAP.md)

---
_Source: https://npm.io/package/lighter-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
