Skip to content

Instantly share code, notes, and snippets.

@vcheckzen
Last active December 11, 2021 09:03
Show Gist options
  • Save vcheckzen/69c645a54802fe558002f09f24ce2614 to your computer and use it in GitHub Desktop.
Save vcheckzen/69c645a54802fe558002f09f24ce2614 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
jq() {
python3 -c "$(
cat <<EOF
import sys, json
json.dump($1$2, sys.stdout, separators=(',', ':'), ensure_ascii=False)
EOF
)"
echo
}
es() {
jq "'$1'"
}
username="logi"
password='abc"def'
app_id=111
client_secret="2fd.s3420"
reply_uri="app://e5"
app="$(
cat <<EOF
{
"username": "$username",
"password": $(es "$password"),
"client_id": $app_id,
"client_secret": "$client_secret",
"redirect_uri": "$reply_uri"
}
EOF
)"
echo "$app"
jq "$app" '["password"]'
# output
# {
# "username": "logi",
# "password": "abc\"def",
# "client_id": 111,
# "client_secret": "2fd.s3420",
# "redirect_uri": "app://e5"
# }
# "abc\"def"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment