#!/usr/bin/perl use strict; use warnings; use 5.010; use utf8; use YAML::XS qw/ Load /; use JSON::PP; my $yaml = do { local $/; <> }; $yaml =~ s{^ *//.*$}{}mg; my $data = Load($yaml); my $coder = JSON::PP->new; $coder = $coder->canonical(1); $coder = $coder->ascii->pretty; print $coder->encode($data);