← 返回命令列表

Linux command

oq 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Query JSON

oq '.[0]' [file.json]

Convert YAML to JSON

oq -i yaml '.' [file.yaml]

Query XML and output as YAML

oq -i xml -o yaml '.root.element' [file.xml]

说明

oq is a performant, portable jq wrapper that adds support for consuming and outputting formats beyond JSON, including XML and YAML. All jq filters work as expected — oq handles format conversion on input and output transparently.

参数

-i _FORMAT_
Input format (json, yaml, xml). Default: json.
-o _FORMAT_
Output format (json, yaml, xml). Default: json.
--xml-root _NAME_
Root element name when transcoding to XML. Default: root.
--indent _N_
Number of spaces per indentation level (default: 2).
--tab
Use tabs instead of spaces for indentation.
-h, --help
Display help. All other arguments are passed through to jq.

FAQ

What is the oq command used for?

oq is a performant, portable jq wrapper that adds support for consuming and outputting formats beyond JSON, including XML and YAML. All jq filters work as expected — oq handles format conversion on input and output transparently.

How do I run a basic oq example?

Run `oq '.[0]' [file.json]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i _FORMAT_ do in oq?

Input format (json, yaml, xml). Default: json.