[d24f17c] | 1 | # jsonify <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
| 2 |
|
---|
| 3 | [![github actions][actions-image]][actions-url]
|
---|
| 4 | [![coverage][codecov-image]][codecov-url]
|
---|
| 5 | [![License][license-image]][license-url]
|
---|
| 6 | [![Downloads][downloads-image]][downloads-url]
|
---|
| 7 |
|
---|
| 8 | [![npm badge][npm-badge-png]][package-url]
|
---|
| 9 |
|
---|
| 10 | This module provides Douglas Crockford's JSON implementation without modifying any globals.
|
---|
| 11 |
|
---|
| 12 | `stringify` and `parse` are merely exported without respect to whether or not a global `JSON` object exists.
|
---|
| 13 |
|
---|
| 14 | [](https://travis-ci.org/ljharb/jsonify)
|
---|
| 15 |
|
---|
| 16 | # methods
|
---|
| 17 |
|
---|
| 18 | ``` js
|
---|
| 19 | var json = require('jsonify');
|
---|
| 20 | ```
|
---|
| 21 |
|
---|
| 22 | ## json.parse(source, reviver)
|
---|
| 23 |
|
---|
| 24 | Return a new javascript object from a parse of the `source` string.
|
---|
| 25 |
|
---|
| 26 | If a `reviver` function is specified, walk the structure passing each name/value pair to `reviver.call(parent, key, value)` to transform the `value` before parsing it.
|
---|
| 27 |
|
---|
| 28 | ## json.stringify(value, replacer, space)
|
---|
| 29 |
|
---|
| 30 | Return a string representation for `value`.
|
---|
| 31 |
|
---|
| 32 | If `replacer` is specified, walk the structure passing each name/value pair to `replacer.call(parent, key, value)` to transform the `value` before stringifying it.
|
---|
| 33 |
|
---|
| 34 | If `space` is a number, indent the result by that many spaces.
|
---|
| 35 | If `space` is a string, use `space` as the indentation.
|
---|
| 36 |
|
---|
| 37 | # install
|
---|
| 38 |
|
---|
| 39 | With [npm](https://npmjs.org) do:
|
---|
| 40 |
|
---|
| 41 | ```
|
---|
| 42 | npm install jsonify
|
---|
| 43 | ```
|
---|
| 44 |
|
---|
| 45 | To use this module in the browser, check out
|
---|
| 46 | [browserify](https://github.com/browserify/browserify).
|
---|
| 47 |
|
---|
| 48 | # license
|
---|
| 49 |
|
---|
| 50 | public domain
|
---|
| 51 |
|
---|
| 52 | [package-url]: https://npmjs.org/package/jsonify
|
---|
| 53 | [npm-version-svg]: https://versionbadg.es/ljharb/jsonify.svg
|
---|
| 54 | [deps-svg]: https://david-dm.org/ljharb/jsonify.svg
|
---|
| 55 | [deps-url]: https://david-dm.org/ljharb/jsonify
|
---|
| 56 | [dev-deps-svg]: https://david-dm.org/ljharb/jsonify/dev-status.svg
|
---|
| 57 | [dev-deps-url]: https://david-dm.org/ljharb/jsonify#info=devDependencies
|
---|
| 58 | [npm-badge-png]: https://nodei.co/npm/jsonify.png?downloads=true&stars=true
|
---|
| 59 | [license-image]: https://img.shields.io/npm/l/jsonify.svg
|
---|
| 60 | [license-url]: LICENSE
|
---|
| 61 | [downloads-image]: https://img.shields.io/npm/dm/jsonify.svg
|
---|
| 62 | [downloads-url]: https://npm-stat.com/charts.html?package=jsonify
|
---|
| 63 | [codecov-image]: https://codecov.io/gh/ljharb/jsonify/branch/main/graphs/badge.svg
|
---|
| 64 | [codecov-url]: https://app.codecov.io/gh/ljharb/jsonify/
|
---|
| 65 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/jsonify
|
---|
| 66 | [actions-url]: https://github.com/ljharb/jsonify/actions
|
---|