5 ms·
Is there something similar for YAML? I've tried `yq` briefly but weirdly enough it doesn't seem to accept standard input in the way that jq does (ie pipe in som
by hugg 7y ago
Is there something similar for YAML? I've tried `yq` briefly but weirdly enough it doesn't seem to accept standard input in the way that jq does (ie pipe in some json, and output some pretty json)
- MichaelMoser123 7y agoit shouldn't be too difficult to convert between yaml and json, funny i couldn't find a light weight converter easily. I think i will try to write one.
- brianjlogan 7y agoDoesn't yaml have significantly more baggage as far as "advanced features" that couldn't be properly duplicated in json?
- mason55 7y agoBasic YAML, sure, but YAML has some insane features that I don't think would be possible to replicate in JSON. Or, at least, you'd lose some information in the conversion. For example, YAML supports the concept of reusable fragments. You can define a fragment in one place and reference it further down in your YAML file. A JSON converter could take the final YAML output and turn it into JSON but you would lose the context of the fact that in the original YAML it was an included fragment and not just the same section repeated a few times.
- loeg 7y agoYeah, YAML can also embed arbitrary code in the original Ruby incarnation and that clearly cannot be translated to JSON. Yeah, no straightforward translation of references to JSON. You could provide both translation ramps, but it would be an implementation-specific convention and not something other JSON tools understood.
- moondev 7y agoyq r test.json > test.yaml yq r -j test.yaml > test.json
- kbrazil 7y agojc has a yaml to json converter: cat file.yaml | jc --yaml
- jolmg 7y agoThis comment shared one: https://news.ycombinator.com/item?id=22626664 https://news.ycombinator.com/item?id=22626664
- moondev 7y agoHighly recommend https://github.com/mikefarah/yq https://github.com/mikefarah/yq It can do everything with json as well and convert between
- loeg 7y agoWorth noting OP has tried it and has some critiques. > I've tried `yq` briefly but weirdly enough it doesn't seem to accept standard input in the way that jq does (ie pipe in some json, and output some pretty json)
- ecnahc515 7y agoI use https://github.com/jzelinskie/faq/ https://github.com/jzelinskie/faq/