Skip to content

Instantly share code, notes, and snippets.

@angeloevangelista
Created October 20, 2024 00:35
Show Gist options
  • Select an option

  • Save angeloevangelista/18ab740c840cfe6b94a03ee39fffd147 to your computer and use it in GitHub Desktop.

Select an option

Save angeloevangelista/18ab740c840cfe6b94a03ee39fffd147 to your computer and use it in GitHub Desktop.
Serialize ENV into JSON
#!/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