Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why NDJSON instead of JSON? #9068

Open
alexandernst opened this issue May 31, 2024 · 3 comments
Open

Why NDJSON instead of JSON? #9068

alexandernst opened this issue May 31, 2024 · 3 comments

Comments

@alexandernst
Copy link

yarn info (and others?) output NDJSON instead of JSON and I can't find a reason why you'd have picked NDJSON instead of JSON.

JSON is already very easily parseable with jq and the size increase in the output is negligible compared to NDJSON. Maybe switch to JSON and make it easier to parse yarn's output?

@Daniel15
Copy link
Member

Daniel15 commented Jul 15, 2024

jq should handle newline-delimited JSON fine.

Are you talking about Yarn 1.x or 4.x? This repo is for 1.x, which is frozen and not getting updates.

@alexandernst
Copy link
Author

Sure, jq can handle NDJSON, but why pick NDJSON instead of plain JSON in the first place? It just seems a weird decision given the fact that NDJSON is not that common and, albeit jq handling it properly, there most probably are ton of other tools that wont handle NDJSON.

I believe the output of this particular command is the same for 1.x and 4.x.

@yukha-dw
Copy link

yukha-dw commented Aug 16, 2024

I think what you mean is not NDJSON but something like Object on Javascript?

{
  id: 123,
  name: "John Doe",
  age: 1
}

you can add --json to return as JSON
https://classic.yarnpkg.com/lang/en/docs/cli/info/#toc-yarn-info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants