Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xtao-org/jsonstrum
A high-level wrapper over JsonHilo which emits fully parsed objects and arrays.
https://github.com/xtao-org/jsonstrum
deno json jsonhilo jsonstrum objects parser sax stream streaming
Last synced: 3 months ago
JSON representation
A high-level wrapper over JsonHilo which emits fully parsed objects and arrays.
- Host: GitHub
- URL: https://github.com/xtao-org/jsonstrum
- Owner: xtao-org
- License: mit
- Created: 2022-02-04T00:31:22.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-08-03T13:56:42.000Z (over 1 year ago)
- Last Synced: 2024-10-31T01:49:38.197Z (3 months ago)
- Topics: deno, json, jsonhilo, jsonstrum, objects, parser, sax, stream, streaming
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JsonStrum.js
A high-level wrapper over [JsonHilo](https://github.com/xtao-org/jsonhilo) which emits fully parsed objects and arrays.
Should work in any modern JavaScript runtime: Node.js, Bun, Deno, the browser.
## Install
### Node.js and Bun
An [npm package](https://www.npmjs.com/package/@xtao-org/jsonstrum) is available:
```
npm i @xtao-org/jsonstrum
```### Deno or the browser
Import modules directly from a CDN such as [jsDelivr](https://www.jsdelivr.com/):
```js
import {JsonHigh} from 'https://cdn.jsdelivr.net/gh/xtao-org/[email protected]/mod.js'
```Alternatively in Deno you can also import the npm package:
```js
import {JsonStrum} from 'npm:@xtao-org/jsonstrum'
```## Quickstart
```js
// if using Deno import from 'npm:@xtao-org/jsonstrum'
import {JsonStrum} from '@xtao-org/jsonstrum'const s = JsonStrum({
object: (object) => console.log('object', object),
array: (array) => console.log('array', array),
// will only parse and emit objects at this level of nesting
level: 1,
})s.chunk(`
[
{"name": "Alice", "color": "red", "count": 5},
{"name": "Bob", "color": "blue", "count": 4},
]
`)
/* OUTPUT:
object { name: "Alice", color: "red", count: 5 }
object { name: "Bob", color: "blue", count: 4 }
*/
```