Scroll to navigation

JSON2YAML(1) Configuration Conversion JSON2YAML(1)

NAME

json2yaml - convert JSON configuration files to conf2-compatible YAML format

SYNOPSIS

json2yaml [-h] [-oOUTPUT_DIR] SOURCE...

DESCRIPTION

Converts JSON configuration files to YAML format compatible with conf2 modules. Processes individual JSON files or recursively converts all JSON files in directories. Output files retain original names with .yaml extension.

OPTIONS

Show help message and exit
Specify output directory (default: ~/yaml)
JSON file(s) or directory path(s) to process (at least one required)

CONVERSION RULES

  • JSON objects become nested YAML structures
  • All values gain metadata fields:
_default: Original value
_type: Type indicator ('s' for scalar, 'as' for arrays)
  • Array values are converted to string representations
  • Output version is fixed to 2.0.0.0-0k0.0

OUTPUT

<original_name>.yaml in output directory

<filename>:
2.0.0.0-0k0.0:
<key1>:
_default: <value>
_type: <s|as>
<key2>: ...

ENVIRONMENT

Used when default output directory (~/yaml) is specified

EXAMPLES

json2yaml /etc/app/config.json
json2yaml -o ~/converted /path/to/json_configs/
json2yaml file1.json file2.json ~/legacy_configs

EXIT STATUS

0
Success
1
Input errors (invalid files/paths)
2
Processing errors

NOTES

  • Original JSON arrays become string values in YAML
  • Nested objects are preserved recursively
  • Non-JSON files are skipped with warning

SEE ALSO

conf2(1), jq(1), yq(1)

AUTHOR

UKUI Configuration Tools Team

2025-07-24 v1.1