ead1 App::JYJ
Convert JSON to YAML to JSON to...
=head2 Synopsis
$ cat file.json | jyj # YAML
$ cat file.json | jyj | jyj # JSON
$ cat file.json | jyj | jyj |jyj # YA
ol called C<jyj>.
It reads stdin.
If it looks like JSON, it prints the YAML dump of the JSON decoding.
If it looks like YAML, it prints the JSON encoding of the YAML load.
That's it.
=head2 Autho
nings;
our $VERSION = '0.0.2';
use JSON::PP;
use YAML::PP;
use IO::All;
use Mo;
sub run {
my $input = io('-')->utf8->all;
my $output;
my $json = JSON::PP->new->pretty->indent_length(2);
[]/) {
my $data = $json->decode($input);
$output = $yaml->dump($data);
}
else {
my $data = $yaml->load_string($input);
$output = $json->encode($data);
}