Skip to content

Getting all the values of a JSON object #7

Description

@NyaomiDEV

Hello.

I am having a problem with this library: say I wanted to parse a simple object:

{
	"a": 1,
	"b": 2,
	"c": [
		"this",
		"that"
	],
	"d": {
		"inside": [],
		"hey": null
	}
} // -> variable `json: ReadableStream<string>` on the other snippet

With the following code:

const stream = json.pipeThrough(parseJsonStreamWithPaths([["a", "b", "c", "d"]]));

for await(const { path, value } of streamToIterable(stream)){
	console.log(path, value);
}

I would expect to have:

[ 'a' ] 1
[ 'b' ] 2
[ 'c', 0 ] this
[ 'c', 1 ] that
[ 'd', 'inside' ] []
[ 'd', 'hey' ] null

But instead it either crashes or gives me:

[ 'c', 0 ] this
[ 'c', 1 ] that
[ 'd', 'inside' ] []
[ 'd', 'hey' ] null

What am I missing on?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions