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

Support YAML #10

Open
01mf02 opened this issue Jun 7, 2022 · 4 comments
Open

Support YAML #10

01mf02 opened this issue Jun 7, 2022 · 4 comments

Comments

@01mf02
Copy link
Owner

01mf02 commented Jun 7, 2022

The main difference between serde_json and serde_yaml seems to be that in YAML, map keys can be any value, whereas in JSON, map keys can be only strings.

We could lift the restriction on the key type to allow for YAML support quite quickly; however, the main blocker seems to be colored output of YAML values. This would then require a crate like colored_yaml --- which does not exist for now.

@martinohmann
Copy link

@01mf02 There is syntect which provides syntax highlighting for YAML as well. It's a pretty heavyweight dependency though, so not sure if this is what you are looking for.

@01mf02
Copy link
Owner Author

01mf02 commented Jun 20, 2022

@martinohmann: Thanks for the suggestion, but I suppose that this solution would be too slow, because it would require outputting YAML first as text, then parsing it with syntect, and only then outputting it.

@yerke
Copy link

yerke commented Oct 15, 2023

I think it would be beneficial to add support for YAML even without colors at first. If you want, you could just hide support for YAML before some runtime experimental flag (--experimental-yaml or something like it), so people would adjust their expectations accordingly.

@simonrupf
Copy link
Contributor

For what it is worth, I had the same need and created yet another yaml-to-json wrapper based on serde: https://github.com/simonrupf/convert2json

That project includes a yq binary that supports passing through arguments to jaq or jq (if both are installed, jaq is preferred), piping any converted yaml files as json over standard input into it.

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

4 participants