Open ghost opened 5 years ago
Thanks for the suggestion. I have a hard time believing that there are a lot of use cases for converting XML to YAML. I'd probably be OK with adding an option for configuring this (I'm not OK with changing the default).
@kislyuk thanks, I dont do a lot of XML => YAML conversion, but I noticed that XML can be more expressive since it has attributes. JSON and YAML dont, but you can fake them in different ways. It is interesting to see how different people represent XML as JSON or YAML.
This is with reference to https://github.com/kislyuk/yq/issues/74#issue-516392109
Pardon me for asking this but were command line options added to override the "@" and "#" prefixes in the output of xq ?
i would love to have this as i would want to use the output json in json-ld where "@" is used as a 'directive' prefix.
i did'nt see these options in the cli documentation and hence this question.
Hi @ksridhar - there is no command line option to customize this behavior. PRs are welcome.
When it comes to XML attributes, XQ prepends with
@
:my issue is that with YAML
@
requires quoting:Other characters are available that dont require quoting, for example:
Here are others:
To counter myself, some would point to this page:
https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
Which is referenced by multiple repos:
Further as
@
represents the "at sign", it is similar to "attribute" and so easy to remember. However I would make a couple of points. The xml.com page above has no mention of YAML, and as such I think its validity is weakened in regards to a YAML repo. Futher, I think it would be helpful to use a character that "plays nice" or is the "least bad" across XML, JSON and YAML, and that is not the@
character.Ideally I would say the default should be changed to
$
or similar, but if the default stays and an option is added to XQ, that would be acceptable as well. I did find these documents in support of$
character: