ワンライナーでJSON APIの結果を整形して出力するスクリプト

curlの結果を

python3 -c "import sys, json;dict=json.loads(input());print(json.dumps(dict, indent=4, separators=(',', ': '), ensure_ascii=False))"

にパイプで渡す

curl "https://api.ipify.org/?format=json" | python3 -c "import sys, json;dict=json.loads(input());print(json.dumps(dict, indent=4, separators=(',', ': '), ensure_ascii=False))"
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.