![]() yaml extension, and follow specific syntax rules. Transcoding is available with the tomlq -toml-output/ tomlq -t option.YAML files use a. Tomlkit library to transcode TOML to JSON, then pipes it to jq. The yq package installs an executable, tomlq, which uses the ![]() Entity expansion and DTD resolution is disabled to avoid The full doc into memory (for example, stream a Wikipedia database dump withĬat enwiki-*.xml.bz2 | bunzip2 | xq. Use -xml-item-depth to descend into large documents, streaming their contents without loading Multiple XML documents can be passed in separate files/streams as The yq package installs an executable, xq, which Check your jq filter for compatibility/semantic validity when using the -Y option. A filter that expects all array entries to be mappings may break due to the presence of string For example, a jq filter that counts entries in the Instances array will come up withĤ entries instead of 2. The -Y option is incompatible with jq filters that do not expect the extra information injected into the document Parses this metadata, re-applies the tags and styles, and discards the extra pairs and values. When converting the JSON back into YAML, it Representation of your document for any custom tags or styles that it finds. To accomplish this in -Y mode, yq carries extra metadata (mapping pairs and sequence values) in the JSON ![]() Resources.ElasticLoadBalancer will preserve tags and styles: Type: 'AWS::ElasticLoadBalancing::LoadBalancer' Good thing it''s managed by this template.'īy contrast, passing it through yq -Y. Resources.ElasticLoadBalancer will drop custom tags, such as !Ref,Īnd styles, such as the folded style of the Description field: Type: AWS::ElasticLoadBalancing::LoadBalancerĭescription: 'Load balancer for Big Important Service. Good thing it's managed by this template. Type: 'AWS::ElasticLoadBalancing::LoadBalancer' For example, consider the followingĭocument (an AWS CloudFormation template fragment): Resources: The -Y option helps preserve custom string styles and Preserving tags and styles using the -Y ( -yaml-roundtrip) option See the jq manual for more details on jqīecause YAML treats JSON as a dialect of YAML, you can use yq to convert JSON to YAML: yq -y. yq forwards the exit code jq produced, unless there was an error in YAML parsing, in whichĬase the exit code is 1. All other command line arguments areįorwarded to jq. ![]() Use the -width/ -w option to pass the line wrap width for string literals. With -y/-Y, files can be edited in place like with sed -i: python -m yq -Y -indentless -in-place '. Option to preserve YAML tags and styles by representing them as extra items in their enclosing mappings and sequences Use the -yaml-output/ -y option to convert it back into YAML: cat input.yml | yq -y. foo.bar input.ymlīy default, no conversion of jq output is done. Like in jq, you can also specify input filename(s) as arguments: yq. ![]() Yq takes YAML input, converts it to JSON, and pipes it to jq: cat input.yml | yq. On macOS, yq is also available on Homebrew: use brew install python-yq. See the jq installation instructions for details and directions specific to your platform. Yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents Installation pip install yqīefore using yq, you also have to install its dependency, jq. ![]()
0 Comments
Leave a Reply. |