denoland / denoland/std

Add support streaming json parsing from array of objects

Open
#5,675 1 comment 2 reactions 0 assignees View on GitHub
feedback welcome
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

The problem: there is a massive array of objects, and it is very, very large, I want to be able to parse this array in parts, object-wise.

```ts
new Response(`[{}, {}, {},\n{},\t{}...]`)
// transform
transformed = ...

for await (const line of transformed) {
const obj = JSON.parse(line)
}
````

**Describe the solution you'd like**

Add transformer that supports top level array or array by path (Eg: `{data: [{}, {}, {}]}`

Good: https://pkg.go.dev/encoding/json#Decoder, https://pkg.go.dev/encoding/json#example-Decoder.Decode-Stream

**Describe alternatives you've considered**

The npm ecosystem is full of solutions that are very poorly made or just very slow and resource intensive

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.