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

pipeline use? #16

Closed
luckman212 opened this issue Jun 29, 2024 · 6 comments
Closed

pipeline use? #16

luckman212 opened this issue Jun 29, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@luckman212
Copy link

I'm using Darwin arm64 binary downloaded from releases on macOS 14.5 (it self-reports as v0.0.8)

I was hoping to use the CLI in a shell pipeline.

When I tried

$ echo "{'employees':['John', 'Anna', " | jsonrepair -f /dev/stdin

I get the somewhat unexplainable output below:

{}
---
{"employees":["John","Anna"]}

What is the --- and extra null output {} above it?

I notice that this seems to work though:

$ echo "{'employees':['John', 'Anna', " | jsonrepair -i "$(</dev/stdin)"
{"employees":["John","Anna"]}
@luckman212 luckman212 added the bug Something isn't working label Jun 29, 2024
@luckman212
Copy link
Author

I looked at the source, seems like this is where it's coming from:

if file != "" {
if input != "" {
fmt.Println("---")
}

It seems to think that there's both file (-f) and input (-i) being supplied, when in fact there isn't. I even get that kind of result with e.g.

$ echo "{ foo: 1 }" >test.json
$ jsonrepair -f test.json
{}
---
{"foo":1}

But, always passing -i '' gets rid of it.

$ jsonrepair -f bad.json -i ''
{"foo":1}

Is this expected behavior?

@luckman212 luckman212 changed the title NOT_A_BUG: pipeline use? pipeline use? Jun 29, 2024
@RealAlexandreAI
Copy link
Owner

I will adjust to a better strategy at an appropriate time after work, and add automated unit tests for the pipeline use scenario.

@RealAlexandreAI
Copy link
Owner

fixed in 0.0.11.

@luckman212
Copy link
Author

@RealAlexandreAI Thank you for taking the time, but, am I crazy or is this still a little broken?

$ jsonrepair -v
Version: 0.0.11

$ echo "{ foo: 1 }" >test.json

$ jsonrepair -f test.json
{}

$ jsonrepair -i '' -f test.json
{"foo":1}

Why does jsonrepair -f test.json return no output?

@RealAlexandreAI
Copy link
Owner

Sorry for this matter. I made a simple repair during the weekend.
Now I have made a new release 0.0.13 and added relatively comprehensive unit tests.
The root cause of the problem is due to the incorrect initial value of '-i'.

I will keep this issue open until you verify all of your scenarios.

@luckman212
Copy link
Author

0.0.13 LGTM! Thanks for digging into it. This is an amazing tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants