| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | use 5.014002; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use File::ShareDir qw[dist_file]; | ||
| 8 | use File::Slurp; | ||
| 9 | |||
| 10 | use Zonemaster::Engine::Profile; | ||
| 11 | |||
| 12 | my $json_file = @ARGV ? $ARGV[0] : dist_file( 'Zonemaster-Engine', 'profile.json'); | ||
| 13 | my $json = read_file( $json_file ); | ||
| 14 | my $profile = Zonemaster::Engine::Profile->from_json( $json ); | ||
| 15 | my $yaml = $profile->to_yaml(); | ||
| 16 | say $yaml; | ||
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | json2yaml - Convert a JSON profile into YAML | ||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | ./json2yaml.pl | ||
| 25 | ./json2yaml.pl profile.json | ||
| 26 | |||
| 27 | =head1 DESCRIPTION | ||
| 28 | |||
| 29 | json2yaml converts a JSON profile into YAML. The JSON profile can be passed as | ||
| 30 | an argument. If no argument is provided, the script will look for the default | ||
| 31 | profile. The YAML profile is written to the standard output. | ||
| 32 | |||
| 33 | =cut |