← 返回
未分类 中文

jyml

This skill should be used when the user asks to "convert YAML to JSON", "convert JSON to YAML", "transform YAML file", "transform JSON file", "convert config...
当用户请求将YAML转换为JSON、将JSON转换为YAML、转换YAML文件、转换JSON文件或转换配置时使用此技能。
waldekmastykarz
未分类 clawhub v0.2.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 253
下载
💾 0
安装
1
版本
#latest

概述

jyml - YAML ↔ JSON Converter

Zero-config CLI for converting between YAML and JSON formats. Pass a file, get the converted file. No flags required.

Prerequisites

Ensure jyml is available:

# Check if installed
which jyml

# Install globally if needed
npm install -g jyml

# Or use npx for one-off conversions
npx jyml <file>

Requires Node.js 18 or later.

Basic Usage

jyml <file> [options]

The CLI auto-detects the input format based on file extension and converts to the opposite format:

Input ExtensionOutput Extension
-----------------------------------
.yaml, .yml.json
.json.yaml

Output is written to the same directory with the swapped extension.

Options

OptionDescriptionDefault
------------------------------
-o, --output Custom output file pathInput file with swapped extension
--jsonPrint structured JSON to stdout (no file written)
--indent Indentation spaces2
-h, --helpShow help
-V, --versionShow version

Common Workflows

Convert a single file

# YAML to JSON
jyml config.yaml
# → writes config.json

# JSON to YAML
jyml settings.json
# → writes settings.yaml

Convert with custom output path

jyml docker-compose.yml -o ./output/docker-compose.json

Convert with custom indentation

jyml response.json --indent 4

Extract data programmatically

Use --json to get structured output for piping to other tools:

# Get parsed content
jyml workflow.yml --json | jq '.content'

# Extract specific values
jyml .github/workflows/ci.yml --json | jq '.content.jobs'

Batch conversion

Convert multiple files using shell patterns:

# Convert all YAML files in a directory
for f in configs/*.yaml; do jyml "$f"; done

# Convert all JSON files
for f in data/*.json; do jyml "$f"; done

Output Modes

Default mode (file output)

Writes converted content to a file, prints progress to stderr:

jyml config.yaml
# stderr: Converting config.yaml → config.json
# Creates: config.json

Structured mode (--json)

Prints structured JSON to stdout, no file written:

{
  "input": "/path/to/input.yaml",
  "format": "json",
  "output": "/path/to/input.json",
  "content": { ... }
}
FieldTypeDescription
--------------------------
inputstringAbsolute path to the source file
formatstringOutput format: "json" or "yaml"
outputstringPath where the file would be written
contentobjectThe parsed and converted data

Exit Codes

CodeMeaning
---------------
0Success
1Conversion error (invalid YAML/JSON, I/O failure)
2Invalid usage (missing file, bad arguments, unsupported extension)

Error Handling

Errors are printed to stderr with actionable context:

Error: File not found: config.yaml
Error: Unsupported file extension ".txt". Supported: .yaml, .yml, .json
Error: Invalid YAML: bad indentation of a mapping entry (1:11)
Error: Invalid JSON: Expected property name or '}' in JSON at position 2

When conversion fails, check:

  1. File exists and is readable
  2. File extension is .yaml, .yml, or .json
  3. File contains valid YAML or JSON syntax

Use Cases

OpenAPI/Swagger specs

Convert specs between formats for different tools:

# Convert OpenAPI spec to JSON for code generators
jyml openapi.yaml

# Convert back to YAML for documentation
jyml openapi.json

Configuration files

Switch config formats based on tool requirements:

# ESLint config to YAML
jyml .eslintrc.json

# Docker Compose to JSON
jyml docker-compose.yml

GitHub Actions workflows

Parse workflow files for scripting:

# Extract job names from a workflow
jyml .github/workflows/ci.yml --json | jq '.content.jobs | keys'

API response inspection

Convert JSON responses to readable YAML:

curl -s https://api.example.com/data > response.json
jyml response.json --indent 4
cat response.yaml

版本历史

共 1 个版本

  • v0.2.0 当前
    2026-05-21 14:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

gitload

waldekmastykarz
此技能应在用户请求“下载 GitHub 文件”“从仓库获取文件夹”“获取 GitHub 代码”或“下载 GitHub仓库”时使用。
★ 3 📥 3,477

atifact

waldekmastykarz
当用户请求“提取代理轨迹”、“将HAR转换为轨迹”、“从会话获取轨迹”或“解析代理会话”时使用此技能。
★ 0 📥 277

mdstr

waldekmastykarz
用于在用户请求将 Markdown 转换为 JSON 字符串、转义 Markdown 为 JSON、让 Markdown 符合 JSON 安全或将其嵌入…时使用。
★ 0 📥 276