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

convert from json to yaml have a bug #342

Closed
saturn99 opened this issue Feb 7, 2024 · 3 comments
Closed

convert from json to yaml have a bug #342

saturn99 opened this issue Feb 7, 2024 · 3 comments

Comments

@saturn99
Copy link

saturn99 commented Feb 7, 2024

I have 2 json file (1.json and 2.json)

> ./dyff between 1.json 2.json

image

After I converted them to "yaml"; I execute the above command again for yamel files

​> ./dyff yaml 1.json > 1.yaml
> ./dyff yaml 2.json > 2.yaml
> 
> ./dyff between 1.yaml 2.yaml 
╭ Error occurred
│ failed to load input files: unable to parse data from
│ 1.yaml: yaml: line 43: block sequence entries
│ are not allowed in this context
╵

image

My json file is correct, it parses with jq and can be properly converted to yaml by another tool

dyff version : 1.7.0

@HeavyWombat
Copy link
Member

Thanks for bringing this up. I am somewhat suspecting the JSON to YAML conversation to misbehave. I am looking into it. In the meantime, if you know you feed the files into other tools later, consider using the --plain command-line flag, this is using the standard libraries internally and gives you a plain and simple output. Without this, the content is feed through the code that is also responsible for the coloring, which will be later dropped in case the tool realises the output is redirected anyway.

HeavyWombat added a commit to gonvenience/neat that referenced this issue Feb 10, 2024
Ref: homeport/dyff#342

Make sure to quote the dash in a string.
HeavyWombat added a commit to gonvenience/neat that referenced this issue Feb 10, 2024
Ref: homeport/dyff#342

Make sure to quote the dash in a string.
HeavyWombat added a commit that referenced this issue Feb 10, 2024
Ref: #342

Make sure to quote if string is just a dash by updating the neat version.
@HeavyWombat
Copy link
Member

To be honest, I am not seeing the problem in the content in the screenshot, but I took a guess and was able to get a similar error message when using a dash in a string through the conversion logic. That dash not being quoted is definitely a bug, I am just not sure if it is the same problem you are facing. Let me know if you still have the issue with a new version of dyff once it is released.

HeavyWombat added a commit that referenced this issue Feb 10, 2024
Ref: #342

Make sure to quote if string is just a dash by updating the neat version.
@saturn99
Copy link
Author

saturn99 commented Feb 13, 2024

Unfortunately, I forgot to attach Json's example file that led to the error, and I apologize for that.

out.json:

[
  {"text": "-" }
]

There was a problem with quoting the - sign, which was fixed in version 1.7.1;

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

2 participants