Skip to content

YAML to JSON

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

Usage

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

  • --input is the YAML document to transform

  • --output is the JSON 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 yaml-to-json command.

From files

Reading and writing to files explicitly

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

From stdin / stdout

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

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

From a process

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

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