Created
October 20, 2024 00:35
-
-
Save angeloevangelista/18ab740c840cfe6b94a03ee39fffd147 to your computer and use it in GitHub Desktop.
Serialize ENV into JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| for var in $(printenv); do env_arr="${env_arr}{\"key\":\"${var%%=*}\",\"value\":\"${var#*=}\"},"; done | |
| export ENV_JSON=[${env_arr%,}] | |
| echo "${ENV_JSON}" | jq -r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment