Skip to content

JSON to YAML

This command takes a JSON document and converts it into YAML.

Usage

The json-to-yaml command takes two parameters -input and -output

  • --input is the JSON document to transform

  • --output is the YAML document to be created

  • --output full path is created if it does not exist (like mkdir -p)

You may omit the --input or --output flags to read or write from stdin or stdout

Examples

Below are a few examples for using the json-to-yaml command.

From files

Reading and writing to files explicitly

apigee-go-gen transform json-to-yaml \
  --input ./examples/snippets/ducks.json \
  --output ./out/snippets/ducks.yaml 

From stdin / stdout

Reading from stdin (from a file) and writing to stdout

apigee-go-gen transform json-to-yaml < ./examples/snippets/ducks.json

From a process

Reading from stdin (piped from another process) and writing to stdout

cat ./examples/snippets/ducks.json | apigee-go-gen transform json-to-yaml