# json-stdio

> Write JSON to stdout, encoded for parsing by other processes

Latest version **0.1.112** (published 2019-10-22) · MIT license · 0 weekly downloads

## Install

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

Provides the commands `stdio`, `json_stdio`, `json_stdio_parse`.

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.112 |
| Published | 2019-10-22 |
| First published | 2017-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Olegzandr VD |
| Maintainers | oresoftware |
| Keywords | json, stdout, unix, text, nodejs, npm |

## Links

- npm: https://www.npmjs.com/package/json-stdio
- Repository: https://github.com/ORESoftware/json-stdio
- Homepage: https://github.com/ORESoftware/json-stdio#readme
- Issues: https://github.com/ORESoftware/json-stdio/issues
- npm.io page: https://npm.io/package/json-stdio

## Dependencies (2)

- [@oresoftware/safe-stringify](https://npm.io/package/@oresoftware/safe-stringify.md) 0.0.111
- [@oresoftware/json-stream-parser](https://npm.io/package/@oresoftware/json-stream-parser.md) 0.0.123

## 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

- 0.1.112 (latest) — 2019-10-22
- 0.1.111 — 2019-10-02
- 0.1.109 — 2019-09-10
- 0.1.1011 — 2018-12-23
- 0.1.1010 — 2018-12-19
- 0.1.1009 — 2018-12-01
- 0.1.1008 — 2018-09-18
- 0.1.1007 — 2018-09-18
- 0.1.1005 — 2018-09-14
- 0.1.1004 — 2018-08-04
- 0.1.1003 — 2018-07-13
- 0.0.1017 — 2018-05-20
- 0.0.1016 — 2018-04-18
- 0.0.1015 — 2018-03-16
- 0.0.1014 — 2018-03-15
- … 7 more at https://npm.io/package/json-stdio/versions

## README

# json-stdio

<br>

[![Version](https://img.shields.io/npm/v/json-stdio.svg?colorB=green)](https://www.npmjs.com/package/json-stdio)

<br>

>
> This library allows two Node.js processes to easily communicate via stdout/stderr/stdin.
>

<p>

### Usage / Getting Started

## Importing

```js
import stdio = require('json-stdio');    //   TypeScript
import * as stdio from 'json-stdio';     //   ESNext / ES-Whatever
const stdio = require('json-stdio');     //   Old-Skool
```


## Writing to stdout/stderr (sender process):

```javascript
// log a file path, which can be received by another process

const stdio = require('json-stdio');
const filePath = '/foo/bar';
stdio.log({fp: filePath});
stdio.logerr({fp: filePath});

```


### Parsing a stream  (receiver process)

```javascript
const stdio = require('json-stdio');
const cp = require('child_process');

const k = cp.spawn('bash');

const parser = stdio.createParser();
const stdEventName = stdio.stdEventName;  // '@json-stdio-event'

k.stdout.pipe(parser).on(stdEventName, obj => {
  
    // obj is an object like so:
    // {fp: '/foo/bar'}
});

```

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