Skip to content

Instantly share code, notes, and snippets.

@FrankHassanabad
Last active January 15, 2020 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrankHassanabad/06d2cc93a86992233accaf18abd25da8 to your computer and use it in GitHub Desktop.
Save FrankHassanabad/06d2cc93a86992233accaf18abd25da8 to your computer and use it in GitHub Desktop.
Quick dirty toml to json converter which sorts the keys using jq and yj-macos
#!/bin/sh
# Download yj from:
# https://github.com/sclevine/yj/releases
# such as wget https://github.com/sclevine/yj/releases/download/v4.0.0/yj-macos
#
# Then chmod 755 ./yj-macos and chmod 755 toml_to_json.sh
# Go to your toml and run this
# toml_to_json.sh
rm -rf ./json
mkdir -p json
# "${name//-/_}" Replaces - with _ in the filenames
for f in *.toml ; do
name=$(basename -- "$f" .toml).json
cat $f | ./yj-macos -tj | jq -S . > json/"${name//-/_}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment