Skip to content

Feature request: Native comments-preserving conversion from YAML -> JSONNET #698

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

Closed
ghost opened this issue Aug 13, 2019 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented Aug 13, 2019

In the evolution of piles of YAML to JSONNET, we find ourselves converting YAML -> JSON -> JSONNET a lot. When we do this, YAML comments are dropped in the lossy conversion from YAML -> JSON. However, if the conversion were from YAML -> JSONNET that conversion needn't and shouldn't be lossy with respect to comments.

Thoughts?

Thanks!

@sparkprime
Copy link
Collaborator

sparkprime commented Aug 14, 2019 via email

@sbarzowski
Copy link
Collaborator

sbarzowski commented Aug 14, 2019

This could be pretty useful. I think it should be a completely separate tool, unless there is a some reason for tighter integration.

The only parser that doesn't drop comments that I could find is ruamel.yaml. However comment extraction seems to be far from trivial: https://stackoverflow.com/questions/55130078/yaml-parsing-with-comments-for-doc-purpose

@ghost
Copy link
Author

ghost commented Aug 14, 2019

Thanks for the replies. I looked at ruamel.yaml and https://github.com/mohsen1/yawn-yaml as well, neither of which would easily integrate with either of jsonnet's two implementations. A freestanding tool would be fine with me. Feel free to close this since standalone is the only practical way forward at this time.

@sparkprime
Copy link
Collaborator

Maybe it's possible to use that to make a YAML -> JSON+comments converter, which can then be input into jsonnetfmt.

@sparkprime sparkprime changed the title Feature request: Native conversion from YAML -> JSONNET Feature request: Native comments-preserving conversion from YAML -> JSONNET Aug 28, 2019
@sbarzowski
Copy link
Collaborator

This is tracked by #765.

sbarzowski pushed a commit to sbarzowski/jsonnet that referenced this issue Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants