# express-jsonstream

> Simple middleware for JSON streaming in Express

Latest version **0.0.3** (published 2012-02-29) · 0 weekly downloads

## Install

```sh
npm install express-jsonstream
pnpm add express-jsonstream
yarn add express-jsonstream
bun add express-jsonstream
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2012-02-29 |
| First published | 2012-02-23 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.4.6 <0.7.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Simon Murtha-Smith |
| Maintainers | smurthas |
| Keywords | express, json, streaming |

## Links

- npm: https://www.npmjs.com/package/express-jsonstream
- Repository: https://github.com/smurthas/express-jsonstreaming
- npm.io page: https://npm.io/package/express-jsonstream

## Dependencies (1)

- [json-stream-splitter](https://npm.io/package/json-stream-splitter.md) 0.0.3

## 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.0.3 (latest) — 2012-02-29
- 0.0.2 — 2012-02-29
- 0.0.1 — 2012-02-23

## README

Simple middleware for JSON streaming in Express. Stringifys and sends object delimited by ```\n```'s with the ```Content-Type : application/jsonstream``` header

    var jsonStream = require('express-jsonstream');
    var express = require('express');
    var app = express.createServer(jsonStream());

    app.get('/stream-yo', function(req, res) {
      res.jsonStream({small:'world'});
      res.jsonStream({after:'all'});
      res.end();
    });

    app.post('/stream-yo', function(req, res) {
      req.jsonStream()
      .on('object', console.log)
      .on('response', function(response) {
        if(response.statusCode !== 200) console.error('got non 200 response', response);
      })
      .on('error', console.error).on('end', function() {
        res.send('ok');
      });
    });

    app.listen(8553);
    console.log('listening on', 8553);

You can run the example with:

    node example

a GET to /stream-yo:

    curl "http://localhost:8553/stream-yo" -G -v
    * About to connect() to localhost port 8553 (#0)
    *   Trying 127.0.0.1... connected
    * Connected to localhost (127.0.0.1) port 8553 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
    > Host: localhost:8553
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < X-Powered-By: Express
    < content-type: application/jsonstream
    < Connection: keep-alive
    < Transfer-Encoding: chunked
    <
    {"small":"world"}
    {"after":"all"}
    * Connection #0 to host localhost left intact
    * Closing connection #0

a POST to /stream-yo

    curl "http://localhost:8553/stream-yo" -d "{\"balh\":\"asdasd\"}"$'\n' -H "content-type: application/jsonstream" -v
    * About to connect() to localhost port 8553 (#0)
    *   Trying 127.0.0.1... connected
    * Connected to localhost (127.0.0.1) port 8553 (#0)
    > POST /stream-yo HTTP/1.1
    > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
    > Host: localhost:8553
    > Accept: */*
    > content-type: application/jsonstream
    > Content-Length: 18
    >
    < HTTP/1.1 200 OK
    < X-Powered-By: Express
    < Content-Type: text/html; charset=utf-8
    < Content-Length: 2
    < Connection: keep-alive
    <
    * Connection #0 to host localhost left intact
    * Closing connection #0
    ok

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