# typify-json

> serializing any JavaScript or ECMAScript object to a string which saved the types of partial types like `Date`

Latest version **1.1.2** (published 2015-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install typify-json
pnpm add typify-json
yarn add typify-json
bun add typify-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 | 1.1.2 |
| Published | 2015-12-08 |
| First published | 2015-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yorkie Liu |
| Maintainers | yorkie |
| Keywords | json, shell, serialization |

## Links

- npm: https://www.npmjs.com/package/typify-json
- Repository: https://github.com/weflex/node-typify-json
- Homepage: https://github.com/weflex/node-typify-json#readme
- Issues: https://github.com/weflex/node-typify-json/issues
- npm.io page: https://npm.io/package/typify-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

- 1.1.2 (latest) — 2015-12-08
- 1.1.1 — 2015-12-06
- 1.1.0 — 2015-12-05
- 1.0.3 — 2015-12-05
- 1.0.2 — 2015-12-05
- 1.0.0 — 2015-12-05

## README

# Typify JSON
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Dependency Status][david-image]][david-url]
[![Downloads][downloads-image]][downloads-url]

The library for serializing any JavaScript or ECMAScript object to a string which saved the types of partial
types like `Date`.

The initial purpose to create this module is that I want a string which is serialized from an object, then
will pass the serialized string to mongo shell. The original `JSON.stringify` doesn't fit my need enough 
because it will drop the types of `Date`.

## Installation

```sh
$ npm install typify-json --save
```

## Usage

```js
const typifyJSON = require('typify-json');
console.log(typifyJSON.stringify({
  foo: 'abc',
  bar: {
    date: new Date()
  }
}));
```

Then you will get the following result:

```
{"foo":"abc","bar":{"date":new Date("Fri Dec 21 2012 08:00:00 GMT+0800 (CST)")}}
```

### Work together with mongo shell

```js
const typifyJSON = require('typify-json');
const exec = require('child_process').execSync;

// just insert a document simplify
const obj = {
  foo: 'bar'
};
exec(`mongo --eval '${typifyJSON.stringify(obj)}'`);
```

## API

- [x] `TypifyJSON.stringify(obj[, replacer][, space])`
  - [x] Number
  - [x] Boolean
  - [x] String
  - [x] Date
  - [x] Object
  - [x] Array
  - [x] Null
  - [ ] ObjectId
- [ ] `TypifyJSON.parse(str)`

## License

MIT

[npm-image]: https://img.shields.io/npm/v/typify-json.svg?style=flat-square
[npm-url]: https://npmjs.org/package/typify-json
[travis-image]: https://img.shields.io/travis/weflex/node-typify-json.svg?style=flat-square
[travis-url]: https://travis-ci.org/weflex/node-typify-json
[david-image]: http://img.shields.io/david/weflex/node-typify-json.svg?style=flat-square
[david-url]: https://david-dm.org/weflex/node-typify-json
[downloads-image]: http://img.shields.io/npm/dm/typify-json.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/typify-json

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