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

Feature Suggestion: JSON Lines support #13

Open
w0rp opened this issue Sep 8, 2023 · 0 comments
Open

Feature Suggestion: JSON Lines support #13

w0rp opened this issue Sep 8, 2023 · 0 comments

Comments

@w0rp
Copy link

w0rp commented Sep 8, 2023

It would be a nice bonus feature to be able to fix JSON Lines syntax, if a parameter is provided to switch to a jsonl mode. The added benefit would be being able to take lines of objects from a .json file, copy and paste them into a .jsonl file, remove the outer [ ] surrounding the objects after squishing the data into a single line each, and then having fixjson remove trailing commas where it should. I'm experiencing this need right now as I'm taking data out of a GET REST API response and quickly copy and paste a few lines to POST to another place.

If implemented, I'd add an ALE fixer for running this with the right arguments, plus some default detection of the .jsonl filetype.

High Level Suggested Implementation

In a --jsonl mode, read data from a file a single line at a time, and apply existing fixes to JSON to each line as if it were itself a file, but wrap the fixed output into one compact line. I don't believe we need to do anything to make the output pretty for JSON Lines.

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

1 participant