Convert YAML files to JSON in a directory
There is probably a much better way to do this but I got very excited having this all come together. This "one liner" requires the Perl modules JSON::XS and Catmandu.
find dir/subdir -name "*.yml" -execdir sh -c 'catmandu convert YAML to JSON < {} | json_xs > `basename {} .yml`.json' \;
This is what the script does:
-
Find all yml files and convert them into their JSON equivalents.
-
Pipe the output into json_xs to prettify the JSON.
-
Output the prettified JSON to the same file but with a json extension.